c# - WPF DataGrid set Column width from widthest cell -
I have trouble using the datagroups columns are loaded from the most comprehensive view cell. But if the user scrolls down, and a wider cell appears, then the size of the column changes.
Users do not like it, so I search to cancel this behavior. A simple solution is to set the breadth width, with broad width.
If you have another solution to solve my problem, then it will also be good.
& lt; Window x: class = "win" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006/ Xaml "SizeToContent =" width "& gt; & Lt; Grid & gt; & Lt; Grid.RowDefinitions & gt; & Lt; RowDefinition Height = "Auto" /> & Lt; RowDefinition / & gt; & Lt; /Grid.RowDefinitions> & Lt; Groupbox grid. Row = "0" header = "face" & gt; & Lt; Text box text changed = "text box filter" /> / GroupBox & gt; & Lt; Data Grid Grid.Row = "1" name = "DataGridOperations" AutoGenerateColumns = "false" ColumnWidth = "Auto" CanUserAddRows = "false" CanUserDeleteRows = "false" AlternatingRowBackground = "AntiqueWhite" & gt; & Lt; DataGrid.Columns & gt; & Lt; DataGridTextColumn header = "date" isReadOnly = "right" binding = "{binding date, mode = - bar, StringFormat = {} {0: DD / MM / YYYY HH: mm: ss}}" /> & Lt; DataGridTextColumn header = "type" isReadOnly = "true" binding = "{binding type, mode = one time}" /> & Lt; DataGridTextColumn header = "Etat" IsReadOnly = "True" binding = "{binding status, mode = one time}" /> & Lt; DataGridTextColumn header = "name" isReadOnly = "true" binding = "{binding name, mode = one time}" /> & Lt; DataGridTextColumn Header = "Code" Binding = "{Binding CodeProduct, Mode = OneTime}" /> & Lt; DataGridTextColumn header = "version" isReadOnly = "true" binding = "{binding version indus, mode = one time}" /> & Lt; /DataGrid.Columns> & Lt; / Data grid & gt; & Lt; / Grid & gt; & Lt; / Window & gt;
Ignore the filter module that is disabled on the loading stage. I use C # 4.0 .NET.
What if only the column width should be set to *, in XML:
width = "*"
and a celltemplate that creates textwrapping allowes column width like this continuous Creating Cheers, (maybe using a texblock for that)
Comments
Post a Comment