특정 셀을 기반으로 취소 선을 바인딩하려는 경우 DataGridTextColumn.Binding이 TextBox.Text의 내용 만 변경하기 때문에 바인딩 문제가 발생합니다.
<Setter Property="TextDecorations"
Value="{Binding RelativeSource={RelativeSource Self},
Path=Text,
Converter={StaticResource TextToTextDecorationsConverter}}" />
당신이 TextBox.Text 다른 뭔가에 바인딩 할 경우에, 당신 인 DataGridRow를 통해 바인드 할 필요가 : Text 속성의 값이 모든 경우 당신은 당신이 텍스트 상자 자체에 바인딩 할 수 있습니다 필요 시각적 트리에서 TextBox의 부모. DataGridRow에는 전체 행에 사용 된 전체 개체에 대한 액세스를 제공하는 Item 속성이 있습니다.
public class SomePropertyToTextDecorationsConverter: IValueConverter {
public object Convert(object value, Type targetType, object parameter,
CultureInfo culture)
{
if (value is bool) {
if ((bool)value) {
TextDecorationCollection redStrikthroughTextDecoration =
TextDecorations.Strikethrough.CloneCurrentValue();
redStrikthroughTextDecoration[0].Pen =
new Pen {Brush=Brushes.Red, Thickness = 3 };
return redStrikthroughTextDecoration;
}
}
return new TextDecorationCollection();
}
public object ConvertBack(object value, Type targetType, object parameter,
CultureInfo culture)
{
throw new NotImplementedException();
}
}
이 말은 전체 열을하고 있다면, 그것을 할 수있는 좋은 방법입니다, 당신은 좋은이 수행
는 컨버터는 것을 가정하는 boolean 형이며, 다음과 같습니다 개별 세포를하는 방법? 또한 필자는 DataGridTextColumn을 쉽게 바인딩 할 수있는 것이 없으므로 코드에서이 작업을 수행해야합니다. – SDK
내가 말했듯이, DataTrigger를 사용하여 특정 셀로 제한하고, 뒤에서 코드를 사용하는 것은 문제가되지 않아야합니다. 단지 번역의 문제 일뿐입니다. –