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
Get CheckboxColumnValue
posted

Hi there,

 i have a small project with a DataGrid where one field is a CheckBoxColumn.

 i set the CheckBox in the Column with the following Style in code behind:

 

UnboundField checkfield = new UnboundField();

ControlTemplate controltemplate;
string xamlControl = "";

xamlControl = @"
<ControlTemplate xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"">
<CheckBox HorizontalAlignment=""Center"" IsChecked=""{Binding Attributes[Used]}"" VerticalAlignment=""Center""/>
</ControlTemplate>"; 

 


byte[] xmlControl = Encoding.ASCII.GetBytes(xamlControl);
MemoryStream stream = new MemoryStream(xmlControl);

controltemplate = (ControlTemplate)XamlReader.Load(stream);

Setter templateSetter = new Setter(CellValuePresenter.TemplateProperty, controltemplate);

Style checkboxcell = new Style(typeof(CellValuePresenter));
checkboxcell.Setters.Add(templateSetter);

checkfield.Settings.CellValuePresenterStyle = checkboxcell; 

 

Everything is working fine and now i come to my problem.

 

i need to read every record in the grid  and extract the boolean IsChecked-Value of the CheckBoxColumn for each record.

How do i handle this?

 

regards

Cloud