내 XAML 코드 Background에서 특정 행의 개체 값을 기반으로 각 행 의 색상 을 설정하려고합니다 . 나는이 ObservableCollection의를 z하고, 각각 z라는 속성이 있습니다 State. 나는 내에서 이와 같은 것으로 시작했다 DataGrid.
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="Background"
Value="{Binding z.StateId, Converter={StaticResource StateIdToColorConverter}}"/>
</Style>
</DataGrid.RowStyle>
x는 내 ViewModel 클래스의 속성이 아니기 때문에 잘못된 접근 방식입니다.
내 뷰 모델 클래스에서 나는이 ObservableCollection<z>인 ItemsSource이의 DataGrid및 SelectedItem유형을 z.
색상을에 바인딩 할 수 SelectedItem있지만이 경우 DataGrid.
하나의 속성에 따라이 행 배경색을 어떻게 변경할 수 있습니까?
'State' property not found on 'object' ''z' (HashCode=7162954)'. BindingExpression:Path=State; DataItem='z' (HashCode=7162954); target element is 'DataGridRow' (Name=''); target property is 'NoTarget' (type 'Object')내 엔터티가 이것을 보유 할 때 속성 상태를 찾지 못하고 내 데이터베이스에 상태가 열로 표시되는 이유는 무엇입니까?