Вот код:
Xaml:
<UserControl x:Class="Prototype.Forms.UserForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Prototype.Forms"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="400">
<Grid>
<DataGrid Name="MainGrid">
</DataGrid>
</Grid>
</UserControl>
C #:
public partial class UserForm : UserControl
{
public UserForm(IList <Element> list)
{
InitializeComponent();
DataTable dt = new DataTable();
dt.Columns.Add(" ",typeof(bool));
dt.Columns.Add("Iteration");
dt.Columns.Add("View name");
dt.Columns.Add("Type");
for (int i = 0; i < list.Count; i++)
{
DataRow r = dt.NewRow();
r[1] = i.ToString();
r[2] = list[i].Name;
r[3] = "some element type";
dt.Rows.Add(r);
}
MainGrid.ItemsSource = dt.DefaultView;
MainGrid.MouseLeftButtonUp += new MouseButtonEventHandler(CellClick);
}
private void CellClick(object sender, EventArgs e)
{
//Do stuff
}
}
Итак, проблема в том, что я не могу установить несколько флажков. Как только я пытаюсь установить второй флажок, ранее установленный флажок становится не отмеченным.
Событие кнопки мыши было неудачной попыткой сделать так, чтобы флажки оставались отмеченными, но не удалось.