I'm running into issues with column widths in two different areas using the 11.1 release. I have a grid where all columns have Width="*" in their XAML.
First, when we try to export the grid to Excel, all columns are very small. See below:
I also have a customized GroupByRecordPresenter. A grid column is bound to the width of the first xamdatagrid column. Here's the xaml:
<Grid.ColumnDefinitions> <ColumnDefinition Width="{Binding ElementName=grdOrder, Path=DefaultFieldLayout.Fields[0].CellWidthResolved}"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <TextBlock Background="White" Foreground="Black" Text="{Binding Path=Record.ChildRecords, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ATMTextConverter}, ConverterParameter=Instrument}" Margin="0,0,1,0" Grid.Column="0"/>
The result of this binding is below:
You can see some text on the left cut off.
For both the Excel export and the grouping customization, manually changing the column width fixes the layout problems. For example:
In both cases, I just want the column widths to just work when the xamdatagrid column width is set to star. I have been unable to get a usable value from CellWidthResolved or LabelWidthResolved properties.
Hello Dierk,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Thanks Stefan, this pointed me in the direction I needed to go and solved my issue.
Since the Star Width is resolved after the ColumnDefinition is created and LabelWidthResolved is set it is expected that the Binding doesn't work. Also the LabelWidthResolved doesn't have a PropertyChanged notifier, so I created a sample project where I implemented the functionality you want. Basically I created a Style for the LabelPresenter and handled its Loaded event. In the handler I bound the ColumnDefinitio's Width to the LabelPresenter's ActualWidth Property, which has a PropertyChanged notifier.
Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Quick update: I discovered that I had not updated to the latest 11.1 service release from May of last year. This fixed the Excel column width export bug. However, the issue with binding to the LabelWidthResolved field of a column whose width is set to star is still unresolved. I have also been unable to replicate this in a standalone test project.
Hi Dierk,
Would you please try to provide a sample, so that I can try to assist you further.
Thanks!