GridView column header with radioButton

2 posts, 0 answers
  1. Suneel kumar
    Suneel kumar avatar
    1 posts
    Member since:
    Feb 2012

    Posted 01 Feb 2012 Link to this post

    Hi,

    We have scenarion where the textboxes column will be enabled based on the status of radio button in the Header.
    The radio buttons in the Column headers are bind to the ViewModel bool properties
    The setter of the Property that is bind to the radio button is not being called when the value is changed.

    Here is how my XAM looks like 

    SourceSearchData is bind to Observable collection.
    What I want to do is if the IsReduceByPercentEnable radio button is selected then enable all the textboxes in that column and disable all the textboxes in IsReduceByUnitsEnable column.

    <telerik:RadGridView x:Name="SaveView" ItemsSource="{Binding SourceSearchData}">
    <telerik:RadGridView.Columns>
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Area}" Width="200" IsFilterable="True">
     <telerik:GridViewDataColumn.Header>
      <TextBlock Text="Area" />
     </telerik:GridViewDataColumn.Header>
    </telerik:GridViewDataColumn>
     <telerik:GridViewDataColumn DataMemberBinding="{Binding Subsidiary}" Width="200" IsFilterable="True">
             <telerik:GridViewDataColumn.Header>
                     <TextBlock Text="Subsidary"/>
                     </telerik:GridViewDataColumn.Header>
             </telerik:GridViewDataColumn>
             <telerik:GridViewDataColumn  Width="150">
             <telerik:GridViewColumn.CellTemplate>
              <DataTemplate>
                     <TextBox IsEnabled="{Binding IsPercentEnable, Mode=TwoWay}" Text="{Binding Percent}"></TextBox>
                    </DataTemplate>
             </telerik:GridViewColumn.CellTemplate>
             <telerik:GridViewDataColumn.Header>
                    <RadioButton IsChecked="{Binding IsReduceByPercentEnable, Mode=TwoWay}" GroupName="source" Content="By Percentage"/>
     </telerik:GridViewDataColumn.Header>
          </telerik:GridViewDataColumn>
          <telerik:GridViewDataColumn Width="150">
          <telerik:GridViewColumn.CellTemplate>
          <DataTemplate>
          <TextBox IsEnabled="{Binding IsUnitsEnable, Mode=TwoWay}" Text="{Binding Unit}" Margin="10,0,10,0" ></TextBox>
          </DataTemplate>
          </telerik:GridViewColumn.CellTemplate>
          <telerik:GridViewDataColumn.Header>
          <RadioButton  IsChecked="{Binding IsReduceByUnitsEnable, Mode=TwoWay}" GroupName="source" Content="By Units"/>
     </telerik:GridViewDataColumn.Header>
            </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
            </telerik:RadGridView>

    I am using Silverlight 4.0
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 01 Feb 2012 Link to this post

    Hi,

    You can define the Source property of your binding to the ViewModel:

    <RadioButton IsChecked="{Binding IsReduceByPercentEnable,Source="{StaticResource MyViewModel}", Mode=TwoWay}" GroupName="source" Content="By Percentage"/>
     

    Greetings,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top