I am a new in WPF and my question is there a way to set width of column by the most width item in this column?
When I run my app this column looks like this
Word <EXISTING CALIBRATIO
is shrink. This word should be shown entirely like <EXISTING CALIBRATION>
Like when drop down list is open
My code for this column is
<DataGridTemplateColumn Header="{x:Static res:Resources.geo_calib_folder}">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox x:Name="Cb_geometry_calibration"
ToolTip="{x:Static res:Resources.tooltip_chosen_geometry_calibration_folder}"
PreviewMouseWheel="Cb_PreviewMouseWheel"
SelectionChanged="Cb_geometry_calibration_SelectionChanged"
ItemsSource="{Binding Path=GeoCalibrationFolders}"
SelectedItem="{Binding Path=SelectedGeoCalibrationFolder}"
>
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock
Text="{Binding Path=UIRepresentation}" />
</DataTemplate>
</ComboBox.ItemTemplate>
<ComboBox.Style>
<Style TargetType="ComboBox">
<Style.Triggers>
<DataTrigger Binding="{Binding IsGeoCalibFolderBold}"
Value="True">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
<ComboBox.ItemContainerStyle>
<Style TargetType="ComboBoxItem">
<Setter Property="FontWeight" Value="Normal"/>
</Style>
</ComboBox.ItemContainerStyle>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
So, question is there a way to resize this column dynamically according to content?
P.S. I understand that I can hardcode this value like width = 300
, but I would like to find a way to make it dynamically.