This is a migrated thread and some comments may be shown as answers.

GridView column header with radioButton

1 Answer 136 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Suneel kumar
Top achievements
Rank 1
Suneel kumar asked on 01 Feb 2012, 07:00 AM
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

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 01 Feb 2012, 08:20 AM
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 >>

Tags
GridView
Asked by
Suneel kumar
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or