티스토리 뷰

https://stackoverflow.com/a/3708608/4394750

  • null인 경우에 값을 바꾸려면 {Binding TargetNullValue='값'} 이면 충분함 (답변 1)
  • (위 링크에 없음)

    생판 다른 값을 바인딩해서 바꾸려면 DataGridTextColumn에 Binding을 설정하지 않고, <DataGridTextColumn.ElementStyle> 및 EditingElementStyle에서 DataTrigger로 바인딩을 넣자

잘은 모르겠는데 Text 스타일이 Binding에 의해 오버라이드되어서 값을 바꿀 수 없다고 하는 모양. WPF 디버거로 찍어봤을 때 스타일 값으로 설정한 값이 나오기는 합니다.

<DataGridTextColumn Header="내 헤더" Width="*" > // Binding 이 설정되지 않은 점에 주목 (원래대로라면 FirstValue)
    <DataGridTextColumn.ElementStyle>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Text" Value="{Binding Path=FirstValue, Mode=OneWay}" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=SecondValue}" Value="True">
                    <Setter Property="Text" Value="히히히히!" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </DataGridTextColumn.ElementStyle>
    <DataGridTextColumn.EditingElementStyle>
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="Text" Value="{Binding Path=FirstValue, Mode=TwoWay}" />
        </Style>
    </DataGridTextColumn.EditingElementStyle>
</DataGridTextColumn>
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함