Articles in this section
Category / Section

How to prevent resizing the last column, when parent Grid width is less than the child Grid width in WPF ?

1 min read

When you resize the last column of parent grid towards left, the child grid columns go out of view in MasterDetails view of SfDataGrid as the width of the parent grid is lesser than the width of the child grid. Therefore, after resizing you cannot view the remaining child grid columns in view.

The following screenshot illustrates a four child Grid columns that is clipped due to resizing parent Grid in left wards.

C:\Users\ApoorvahR\Desktop\1.jpg

Figure 1: Four child Grid columns clipped due to resizing parent Grid in left wards

To overcome this problem, disable the resizing support for the last column in parent grid and you can achieve this by setting DetailsViewManager.DisableLastColumnResizing attached property as true, as per the following code example.

XAML

<Window x:Class="DetailsViewSimple.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Local="clr-namespace:DetailsViewSimple"
        xmlns:syncfusion="http://schemas.syncfusion.com/wpf">
<syncfusion:SfDataGrid x:Name="dataGrid" 
                   AllowResizingColumns="True"
                   AllowResizingHiddenColumns="True"
                   HideEmptyGridViewDefinition="True"
                   syncfusion:DetailsViewManager.DisableLastColumnResizing="True"
                   ItemsSource="{Binding Path=OrdersDetails}"> 
</syncfusion:SfDataGrid>

 

Conclusion

I hope you enjoyed learning about how toprevent resizing the last column, when parent Grid width is less than the child Grid width in WPF.

You can refer to our WPF DataGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF DataGrid example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied