Hi,
is it possible to define a FieldLayout in a ResourceDictionary (own XAML and directory) ?
FieldSetting and FieldLayoutSettings work well.
Resourcedictionary.xaml
<igDP:FieldSettings x:Key="Settings1" AllowEdit="False" AllowGroupBy="False" AllowRecordFiltering="True" CellClickAction="EnterEditModeIfAllowed" />
<igDP:FieldLayoutSettings x:Key="Settings2" AllowAddNew="False" AllowDelete="False" AllowRecordFixing="Top" AutoFitMode="Always" HighlightAlternateRecords="True" />
MainWindow.xaml
<igDP:XamDataGrid x:Name="xamDataGrid" FieldLayoutSettings="{DynamicResource Settings2}" FieldSettings="{DynamicResource Settings1}" />
But how i will get a FieldLayout to work like this:
<igDP:FieldLayout x:Key="FieldLayout1"> <igDP:FieldLayout.Fields> <igDP:Field Name="name" /> <igDP:Field Name="department" /> <igDP:Field Name="salary" /> <igDP:Field Name="email" /> </igDP:FieldLayout.Fields> </igDP:FieldLayout>
Thanks in advanced.
Edit. DataSource is bind programmaticly on ClickEvent in Code behind (VB.net)
Hello,
I was not able to understand the second part of your question. Yes, you can define a layout in a resource dictionary or in any resources as long as you set the x:Key property.
>"But how i will get a FieldLayout to work like this:"
You cannot define a FieldLayout unless you know what the DataSource looks like. If you do not know the DataSource, the FieldLayout has to be defined in runtime, because you do not know the names of the fields.
I know the DataSource. The problem is, if i define the FieldLayout directly in the DataGrid it works. Collapsed Columns are not shown etc.
Example:
<igDP:XamDataGrid x:Name="igdgridArt" Theme="Office2k7Blue">
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:FieldLayout.RecordFilters>
<igDP:RecordFilter FieldName="ID">
<igWindows:ComparisonCondition Operator="Equals" Value="12" />
</igDP:RecordFilter>
</igDP:FieldLayout.RecordFilters>
<igDP:Field Name="ID" Visibility="Collapsed" />
<igDP:Field Name="von" />
<igDP:Field Name="bis" >
<igDP:Field.Settings>
<igDP:FieldSettings FilterOperandUIType="DropDownList" />
</igDP:Field.Settings>
</igDP:Field>
<igDP:Field Name="R1" Visibility="Collapsed" />
<igDP:Field Name="Q1" Visibility="Collapsed" />
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
If I define the same FieldLayout in a Resource dictionary with the x:Key Property the Datagrid show nothing. Where must I set the ResourceBinding in the Window and how?
Window.xaml
..
ResourceDictionary.xaml
<igDP:FieldLayout x:Key="FieldLayout1">
Well,
If the FieldLayout is a resource, you have to get it from the resources and apply it to the XamDataGrid - add it in the FieldLayouts collection of the XamDataGrid.
Can you please give an example of defining multiple FieldLayouts as Resources and then loading them from Resources. As XamDataGrid initializes I’d like to dynamically load appropriate FieldLayout.
Thanks!
In the constructor for your view:
uxGrid.FieldLayouts.Clear();uxGrid.FieldLayouts.Add(this.Resources["LayoutResourceKey"] as FieldLayout);