Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144228 | Apr 25,2019 03:53 PM UTC | May 9,2019 09:59 AM UTC | WPF | 10 |
![]() |
Tags: SfDataGrid |
<syncfusion:GridUnBoundColumn MappingName="Closed" SetCellBoundValue="True">
<syncfusion:GridUnBoundColumn.CellTemplate>
<DataTemplate>
<CheckBox HorizontalAlignment="Center" IsChecked="{Binding Value}"
syncfusion:FocusManagerHelper.FocusedElement="True"
VerticalAlignment="Center" Checked="CheckBox_Checked"/>
</DataTemplate>
</syncfusion:GridUnBoundColumn.CellTemplate>
</syncfusion:GridUnBoundColumn> |
public partial class MainWindow : Window
{
Dictionary<object, bool?> checkBoxValues = new Dictionary<object, bool?>();
public MainWindow()
{
InitializeComponent();
this.dataGrid.QueryUnboundColumnValue += DataGrid_QueryUnboundColumnValue;
}
private void DataGrid_QueryUnboundColumnValue(object sender, GridUnboundColumnEventsArgs e)
{
if (e.UnBoundAction == UnBoundActions.QueryData)
{
if (checkBoxValues.ContainsKey(e.Record))
e.Value = checkBoxValues[e.Record];
}
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
var checkBox = sender as CheckBox;
if (checkBox != null && this.dataGrid.CurrentItem != null)
{
if (!checkBoxValues.ContainsKey(this.dataGrid.CurrentItem))
checkBoxValues.Add(this.dataGrid.CurrentItem, checkBox.IsChecked);
checkBoxValues[this.dataGrid.CurrentItem] = checkBox.IsChecked;
this.dataGrid.UpdateUnboundColumn(this.dataGrid.CurrentItem, "Closed");
}
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.