안녕하세요 저는 데이터 박스를 체크 박스로 만들었지 만 체크 박스의 상태를 가져 오는 방법을 모르거나 체크하지 않았습니다. INotifyPropertyChanged를 사용하는 것이 좋습니다. CellEditEnding 이벤트 처리기의 입니다. 제발 내가 donot 알고 어떻게 내가 이들 중 하나를 구현할 수 있습니다.다른 셀의 값 가져 오기 DataGrid WPF
내가 원하는 것은 사용자가 클릭하여 체크/체크하지 않은 체크 박스의 값을 확인하는 것입니다. 해당 행의 첫 번째 셀에서 행 인덱스와 값을 가져올 수 있습니다.
내 코드는 지금까지
namespace embeddatagridcheckbox
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
List<checkedBoxIte> item = new List<checkedBoxIte>();
public MainWindow()
{
InitializeComponent();
for (int i = 0; i < 5; i++)
{
checkedBoxIte ite = new checkedBoxIte();
ite.MyString = i.ToString();
ite.MyBool = false;
item.Add(ite);
}
dataGrid1.ItemsSource = item;
}
}
public class checkedBoxIte
{
public string MyString { get; set; }
public bool MyBool { get; set; }
}
}
XML 당신이에서 CheckBox의 값을 참조 할 않는
<DataGrid AutoGenerateColumns="False" Height="323" HorizontalAlignment="Left" Name="dataGrid1" VerticalAlignment="Top" Width="503" BeginningEdit="dataGrid1_BeginningEdit">
<DataGrid.Columns>
<DataGridTextColumn Header="MyString" Binding="{Binding MyString}" />
<DataGridCheckBoxColumn Header="MyBool" Binding="{Binding MyBool}" />
</DataGrid.Columns>
</DataGrid>
에서 INotifyPropertyChanged의 체크 박스 값이 사용됩니다. UI에서 코드의 개체로의 반대 변경은 기본적으로 작동합니다. – vorrtex