Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
530
Content control in template field
posted

I want to fill the column of xam data grid depend on the selection of another part. 

                <igDP:XamDataGrid Grid.Row="1" DataSource="{Binding UIInputList }" GroupByAreaLocation="None" Grid.ColumnSpan="2" Grid.RowSpan="2">
                    <igDP:XamDataGrid.FieldLayoutSettings>
                                <igDP:FieldLayoutSettings AutoGenerateFields="False" 
                                                        AutoFitMode="Always" 
                                                        AddNewRecordLocation="OnTopFixed"
                                                        AllowAddNew="True"
                                                        SupportDataErrorInfo="RecordsAndCells"
                                                        DataErrorDisplayMode="ErrorIconAndHighlight"
                                                        AllowDelete="True" />
                    </igDP:XamDataGrid.FieldLayoutSettings>
                            <igDP:XamDataGrid.FieldLayouts>
                                <igDP:FieldLayout>
                                    <igDP:FieldLayout.Fields>
                                        <igDP:Field Name="SelectedColumn" Label="Selected column"> </igDP:Field>
                                       
                                        <igDP:TemplateField  Name="CompatibleProperties" Label="Compatible properties"  >
                                            <igDP:TemplateField.EditTemplate>
                                                <DataTemplate>
                                                    <ContentControl Margin="5" Grid.Row="0" Grid.Column="4" Content="{Binding DataContext.InputType, RelativeSource={RelativeSource Mode=FindAncestor,  AncestorType=UserControl}}"
                                                                    ContentTemplateSelector="{StaticResource InputTypeSelector}" Visibility="{Binding DataItem.Selected, Converter={StaticResource inverseBooleantoVisibilityConverter }}" />
                                                </DataTemplate>
                                            </igDP:TemplateField.EditTemplate>
                                        </igDP:TemplateField>
                            </igDP:FieldLayout.Fields>
                        </igDP:FieldLayout>
                    </igDP:XamDataGrid.FieldLayouts>
                </igDP:XamDataGrid>

Here is my xaml code. 

depend on selection, I want to fill my compatible property column from the one of the data template below 

    <DataTemplate x:Key="WellTemplate" DataType="stochasticInversion:InputWellTemplate">
        <controls:DropDownList VerticalAlignment="Center" HorizontalAlignment="Stretch"
                                                VerticalContentAlignment="Center"
                                                IsReadOnly="True"
                                                ItemsSource="{Binding DataContext.CompatibleWellLogVersions, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource Mode=FindAncestor,  AncestorType=ContentControl}}"
                                                SelectedItem="{Binding DataContext.SelectedWellLogVersion, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource Mode=FindAncestor,  AncestorType=ContentControl}}"
                                                IsTextSearchEnabled="True" IsEnabled="{Binding DataContext.Selected, Converter={StaticResource inverseBooleanConverter}, RelativeSource={RelativeSource Mode=FindAncestor,  AncestorType=ContentControl}}"
                                                />
    </DataTemplate>


    <DataTemplate x:Key="GridTemplate"  DataType="stochasticInversion:InputGridTemplate">

        <controls:DropDownList VerticalAlignment="Center" HorizontalAlignment="Stretch"
                                                VerticalContentAlignment="Center"
                                                IsReadOnly="True"
                                                ItemsSource="{Binding DataContext.CompatibleProperties, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource Mode=FindAncestor,  AncestorType=ContentControl}}"
                                                SelectedItem="{Binding DataContext.SelectedProperty, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource Mode=FindAncestor,  AncestorType=ContentControl}}"
                                                IsTextSearchEnabled="True" IsEnabled="{Binding DataContext.Selected, Converter={StaticResource inverseBooleanConverter}, RelativeSource={RelativeSource Mode=FindAncestor,  AncestorType=ContentControl}}"
                                                 />

    </DataTemplate>

But It lokks like I am having a problem with binidngs, How can I fix it ?

Parents
No Data
Reply
  • 34830
    Offline posted

    Hello GG,

    I have been investigating into the behavior you are reporting, and from the code you have provided, it looks to me like the bindings that are likely giving you issues in this case are probably all of the bindings on your DropDownList controls as well as the Visibility binding on the ContentControl. Please let me know if this is incorrect as the following is based upon this impression.

    The reason the bindings on the DropDownList control elements are not working is likely because the DataContext of the ContentControl is not the owning DataRecord like it is in other Field types. The TemplateField works a little differently. In this case, I would recommend that you instead bind to the TemplateEditor whose DataContext is the DataRecord, and bind to DataContext.DataItem.<property path off data item>. This should resolve the binding issues you are currently seeing. For more information on this, I would recommend taking a look at our TemplateField online documentation, here.

    Please let me know if you have any other questions or concerns on this matter.

Children
No Data