Hi,
I would like to set the cell width of a column in a separate style. We have lots of columns and grids and want to set this property on a central place. I know how to do it locally:
<igDP:Field Name="Idx" Label="No." ToolTip="Number"> <igDP:Field.Settings> <igDP:FieldSettings CellWidth="100" /> </igDP:Field.Settings></igDP:Field>
But how to do it in a Style?
Thanks for your help!
BRStephan
Hello Stephan,
Thank you for your post. I have been looking into and I can suggest create a Style for the LabelPresenter like this:
<Style TargetType="{x:Type igDP:LabelPresenter}" x:Key="lp" > <Setter Property="Width" Value="200"/> </Style>
And if it is with key, you can apply it like this:
<igDP:Field Name="LastName" Width="Auto"> <igDP:Field.Settings> <igDP:FieldSettings LabelPresenterStyle="{StaticResource lp}"/> </igDP:Field.Settings> </igDP:Field>
Hope this helps you.
Hi Stefan,
thanks for your quick response! I've tested what you've proposed. The header label is now set to the width defined in the style (the labeling of "Idx"), but not the complete column. See the screenshot attached.
You I can suggest you add the following Styles:
<Style TargetType="{x:Type igDP:LabelPresenter}" x:Key="lp" > <Setter Property="MinWidth" Value="200"/> </Style> <Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="cvp" > <Setter Property="MinWidth" Value="200"/> </Style>
And set the Field like this:
<igDP:Field Name="LastName" Width="Auto"> <igDP:Field.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource cvp}" LabelPresenterStyle="{StaticResource lp}"/> </igDP:Field.Settings> </igDP:Field>
If this doesn’t help you, could please send me an isolated sample project, where the issue is reproduced, so I can investigate it further for you.
Looking forward for your reply.
Hi!
This does not work either. Enclosed you will find a sample project how the grid should look like and behave. In principle what I need is very simple: apply a certain style to a column (i.e. for width).
I have modified the sample you sent me, so now it has the functionality you want. Basically I created an instance of FieldSettings and by using Style for the XamDataGrid, I applied it to all the Fields in the XDG. Please let me know if this helps you or you need further assistance on this matter.
Thanks for your quick response! Unfortunately it does not really match my requirements. Your proposal sets the same column width for all columns. I would need different column widths for specific columns, e.g:
- Column 1 and 2: Width should be 80px (Style "TinyColumn")- Column 3 and 4: Width should be 160px (Style "MediumColumn")- Column 5: Width should be 220px. (Style "LargeColumn")
I assume that in that case the style has to be applied to the corresponding field. But I don't know how to do that.
I have modified the sample I sent you before, so now it has the functionality you want. Basically I created two instance of the FieldSettings and set them to the different Fields.