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
985
How to find control in TemplateColumn of XamWebGrid
posted

I would like to enable or disable a TextBox depending on the ComboBox value.  I tried following code, but couldn't find textblock control. Can someone please help?

C# code:
        editor.SelectionChanged += new SelectionChangedEventHandler(ConditonCombo_SelectionChanged);
               
                - - -
        void ConditonCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
             ComboBox editor = (ComboBox)sender;
             if (editor != null)
             {
                    // find textbox _tblValue2 and enable or disable depending on combo-box value.
             }
        }
               

Xaml Code:
                    <igGrid:XamWebGrid x:Name="_dgAlertConditionsList" HeaderVisibility="Collapsed"  AutoGenerateColumns="False" ColumnWidth="*" Height="300" Width="650" ItemsSource="{Binding AlertConditionList}"  Margin="0,20,0,0">
                        <igGrid:XamWebGrid.SelectionSettings>
                            <igGrid:SelectionSettings CellClickAction="SelectRow" RowSelection="Single"></igGrid:SelectionSettings>
                        </igGrid:XamWebGrid.SelectionSettings>
                        <igGrid:XamWebGrid.EditingSettings>
                            <igGrid:EditingSettings AllowEditing="Row" IsMouseActionEditingEnabled="SingleClick"/>
                        </igGrid:XamWebGrid.EditingSettings>
                        <igGrid:XamWebGrid.Columns>
                            <igGrid:TemplateColumn Key="CondOperator" Width="120" HorizontalContentAlignment="Stretch">
                                <igGrid:TemplateColumn.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock x:Name="CondOperatorDisplay" Text="{Binding CondOperator.Label}"  Margin="3,2,3,2"/>
                                    </DataTemplate>
                                </igGrid:TemplateColumn.ItemTemplate>
                                <igGrid:TemplateColumn.EditorTemplate>
                                    <DataTemplate>
                                        <ComboBox x:Name="CondOperatorList" SelectedItem="{Binding CondOperator,Mode=TwoWay}" DisplayMemberPath="Label" Margin="3,2,3,2"/>
                                    </DataTemplate>
                                </igGrid:TemplateColumn.EditorTemplate>
                            </igGrid:TemplateColumn>
                            - - - -
                            - - -
                            <igGrid:TemplateColumn Key="Value2" Width="*" HorizontalContentAlignment="Stretch">
                                <igGrid:TemplateColumn.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock x:Name="_tblValue2" Text="{Binding Value2}"  Margin="3,2,3,2"/>
                                    </DataTemplate>
                                </igGrid:TemplateColumn.ItemTemplate>
                                <igGrid:TemplateColumn.EditorTemplate>
                                    <DataTemplate>
                                        <TextBox x:Name="_tbValue2" IsEnabled="False" Text="{Binding Value2,Mode=TwoWay}" Margin="3,2,3,2"/>
                                    </DataTemplate>
                                </igGrid:TemplateColumn.EditorTemplate>
                            </igGrid:TemplateColumn>
                        </igGrid:XamWebGrid.Columns>
                    </igGrid:XamWebGrid>

Parents
  • 285
    posted

    I think it would be easier to handle this in the datasource. Add an IsValue2Editable property (or whatever you wanna call it) to your datasource and bind it to the IsEnabled property of the textbox. Then in the setter for whatever property the combobox is bound to just update the IsValue2Editable and fire a PropertyChangedEvent for it.

     

     

Reply Children