이 작업을 수행하려고합니다. 사용자가 DataGrid에서 하나 이상의 셀을 선택하면 모든 중복의 배경색이 변경되어야합니다.. 선택 및 값에 따라 WPF DataGrid 셀의 배경색 변경
public MainWindow()
{
InitializeComponent();
DataTable dt = CreateDataTable();
dataGrid1.ItemsSource = dt.DefaultView;
}
그래서 내가 DataTable에 (10 행, 25 열)를 사용하여 데이터 그리드를 채우는 :
나는
<Window x:Class="NotesOnFretboard.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<DataGrid ItemsSource="{Binding}" AutoGenerateColumns="true" Margin="12,110,12,29" Name="dataGrid1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" IsReadOnly="True" />
</Grid>
</Window>
코드 뒤에이 XAML 있습니다. 이 데이터 테이블에는 여러 중복 값이 있습니다.
사용자가 DataGrid에서 하나 이상의 셀을 선택하면 모든 복제본의 배경색이 변경되어야합니다!
제발 도와주세요!
// 앤더스
? 데이터 구조 란 무엇입니까? 이것은 데이터 구조에 반영하는 것이 훨씬 쉬울 수 있습니다. –
데이터 구조는 ObservablCollection>입니다. Note는 클래스입니다. Note {public string Name {get; 세트; } public int Octave {get; 세트; } public int Midi {get; 세트; }} 그러나 DataGrid에 목록의 목록을 표시하는 방법을 찾지 못했기 때문에 Name 속성을 사용하여 DataTable을 만듭니다. 중복은 미디 속성에 있습니다 –
Andis59