我有 DataGrid 喜欢:
<DataGrid Name="paragonyDG" AutoGenerateColumns="False" CanUserAddRows="False" ItemsSource="{Binding zaznaczone}" >
<DataGrid.Columns>
**<DataGridCheckBoxColumn Header="Zaznacz" Binding="{Binding check}"></DataGridCheckBoxColumn>**
<DataGridTextColumn Header="Nazwa paragonu" Binding="{Binding nazwa}"></DataGridTextColumn>
<DataGridTextColumn Header="Wystawiony przez" Binding="{Binding osoba}"></DataGridTextColumn>
<DataGridTextColumn Header="Kwota paragonu" Binding="{Binding kwota}"></DataGridTextColumn>
<DataGridTextColumn Header="Rabat" Binding="{Binding rabat}"></DataGridTextColumn>
<DataGridTextColumn Header="Data otwarcia" Binding="{Binding dataO}"></DataGridTextColumn>
<DataGridTextColumn Header="Data zamknięcia" Binding="{Binding dataZ}"></DataGridTextColumn>
<DataGridTextColumn Header="Formy płatności" Binding="{Binding formy}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
并将其绑定到类中:
public class zaznaczone
{
public bool check { get; set; }
public int docID { get; set; }
public string nazwa { get; set; }
public string osoba { get; set; }
public decimal kwota { get; set; }
public decimal rabat { get; set; }
public string dataO { get; set; }
public string dataZ { get; set; }
public string formy { get; set; }
}
现在,在 datagrid.selectionchanged 中,我想选中此复选框。我试图将 selectedItem.columns[0] 解析为复选框,但我无法将 datagridrow 解析为“zaznaczone”。我如何检查复选框?