Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WPF
  4. WPF DataGrid with DataGridTemplateColumn and RadioButton

WPF DataGrid with DataGridTemplateColumn and RadioButton

Scheduled Pinned Locked Moved WPF
wpfhelpcsharpwcfquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ausadmin
    wrote on last edited by
    #1

    I have posted the following question on codeplex, but not had any reply. I am hoping someone here may be able to help. I have a WPF DataGrid which represents a small number of options (ie one option per row), one of which is chosen as the default. In the first column of the DataGrid I want to have a RadioButton in each row - to set the default. I have almost got this to work with the code below - the Binding is working. The problem is, it is possible to get into a scenario where the setting from the RadioButton is lost. Our underlying object being bound to implements IEditableObject and we use this in various way to check edits and also take action when the default is changed. I have found that clicking the RadioButton completely bypasses the BeginEdit / EndEdit process of the DataGrid. The xaml is as follows:

                        <toolkit:DataGrid Name="dgTesters" AutoGenerateColumns="False" AlternationCount="2" ItemsSource="{Binding LocalTesters}" 
                                                  CanUserAddRows="false" CanUserDeleteRows="False"  
                                                  SelectionMode="Single" 
                                                  RowEditEnding="dgTesters\_RowEditEnding">
                            <toolkit:DataGrid.Columns>
                                <toolkit:DataGridTemplateColumn>
                                    <toolkit:DataGridTemplateColumn.CellEditingTemplate>
                                        <DataTemplate >
                                            <RadioButton IsChecked="{Binding Path=IsDefault, Mode=TwoWay}" GroupName="a" />
                                        </DataTemplate>
                                    </toolkit:DataGridTemplateColumn.CellEditingTemplate>
                                    <toolkit:DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate >
                                            <RadioButton IsChecked="{Binding Path=IsDefault, Mode=TwoWay}" GroupName="a" />
                                        </DataTemplate>
                                    </toolkit:DataGridTemplateColumn.CellTemplate>
                                </toolkit:DataGridTemplateColumn>
                                <toolkit:DataGridTextColumn Binding="{Binding TesterName}" Header="Tester Name" Width="\*" MinWidth="80" />
                                <!-- Further columns dele
    
    S 1 Reply Last reply
    0
    • A ausadmin

      I have posted the following question on codeplex, but not had any reply. I am hoping someone here may be able to help. I have a WPF DataGrid which represents a small number of options (ie one option per row), one of which is chosen as the default. In the first column of the DataGrid I want to have a RadioButton in each row - to set the default. I have almost got this to work with the code below - the Binding is working. The problem is, it is possible to get into a scenario where the setting from the RadioButton is lost. Our underlying object being bound to implements IEditableObject and we use this in various way to check edits and also take action when the default is changed. I have found that clicking the RadioButton completely bypasses the BeginEdit / EndEdit process of the DataGrid. The xaml is as follows:

                          <toolkit:DataGrid Name="dgTesters" AutoGenerateColumns="False" AlternationCount="2" ItemsSource="{Binding LocalTesters}" 
                                                    CanUserAddRows="false" CanUserDeleteRows="False"  
                                                    SelectionMode="Single" 
                                                    RowEditEnding="dgTesters\_RowEditEnding">
                              <toolkit:DataGrid.Columns>
                                  <toolkit:DataGridTemplateColumn>
                                      <toolkit:DataGridTemplateColumn.CellEditingTemplate>
                                          <DataTemplate >
                                              <RadioButton IsChecked="{Binding Path=IsDefault, Mode=TwoWay}" GroupName="a" />
                                          </DataTemplate>
                                      </toolkit:DataGridTemplateColumn.CellEditingTemplate>
                                      <toolkit:DataGridTemplateColumn.CellTemplate>
                                          <DataTemplate >
                                              <RadioButton IsChecked="{Binding Path=IsDefault, Mode=TwoWay}" GroupName="a" />
                                          </DataTemplate>
                                      </toolkit:DataGridTemplateColumn.CellTemplate>
                                  </toolkit:DataGridTemplateColumn>
                                  <toolkit:DataGridTextColumn Binding="{Binding TesterName}" Header="Tester Name" Width="\*" MinWidth="80" />
                                  <!-- Further columns dele
      
      S Offline
      S Offline
      Suthagar p
      wrote on last edited by
      #2

      Try using Mode=OneWay in the CellTemplate and Mode=TwoWay in the CellEditingTemplate

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups