I have a XamDataGrid with several bound columns and one unbound column, a radio button column. What I want to do when calling InitializeRecord is to set the radiobutton as selected for the first record added ( so there is at least one radiobutton selected ). Here is the style template for the radiobutton:
<Style x:Key="rbInCellStyle" TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="Template">
<Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}" > <RadioButton GroupName="CellButton" HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="False" Click="RB_Click" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Inside InitializeRecord, I do this for the other bound columns:
object typeValue = (e.Record as Infragistics.Windows.DataPresenter.DataRecord).Cells["PeakDefType"].Value;
string tempstr = typeValue.ToString();
(e.Record as Infragistics.Windows.DataPresenter.DataRecord).Cells["TypeAsString"].Value = typeValue;
How do I do something similar for an unbound column?
Hi Kathy,
You could create a property in your data source and bind the radio button to that value. There is a very good sample on our forums using bool and enum properties with radio button in a cellvaluepresenter style. The sample is a little older but it can be updated by setting the framework to 4.0 and then using our version utility to update the assemblies.
http://es.infragistics.com/community/forums/t/29876.aspx
If you’d rather access the first row’s radio button in code then you could use the xamDataGrid’s loaded event. You can't use the InitializeRecord since you are using an unbound column.
I'll attach my sample so that you can see my code. It captures the cellvaluepresenter from the first record and appropriate cell, then passes that cellvaluepresenter to a method that uses a VisualTreeHelper to find the appropriate type of control with the correct name.
Let me know if you have any questions.
I hadn’t heard back from you and I was wondering if I you have any questions.
I'm all set with this issue. Thanks for all your help.
Glad I could help. You are very welcome.