0
내부에 텍스트 상자가있는 DataGridTemplateColumn이 있습니다. 행에 마우스를 가져 가면 텍스트 상자를 제외한 다른 모든 전경이 흰색으로 바뀝니다. 마우스를 행 위로 가져 가면 다른 텍스트 블록/글꼴과 일치하도록 전경 변경되도록 텍스트 상자에 어떤 유형의 스타일을 적용 할 수 있습니까?DataGridTemplateColumn 행 가져 오기 텍스트 상자 전경
예 XAML
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<TextBox Text="Test 123" />
<TextBlock Text="Test 123" />
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
스타일링
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Background"
Value="Transparent" />
<Setter Property="BorderBrush"
Value="{x:Null}" />
<Setter Property="Foreground"
Value="{StaticResource BlackBrush}" />
<Style.Triggers>
<Trigger Property="IsSelected"
Value="True">
<Setter Property="Background"
Value="Transparent" />
<Setter Property="BorderBrush"
Value="{x:Null}" />
<Setter Property="Foreground"
Value="{StaticResource BlackBrush}" />
</Trigger>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
Value="{StaticResource RedBrush}" />
<Setter Property="Foreground"
Value="{StaticResource WhiteBrush}" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Padding"
Value="5, 10" />
<Setter Property="IsTabStop"
Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Border Padding="{TemplateBinding Padding}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="True">
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected"
Value="True">
<Setter Property="Background"
Value="{Binding Path=Background, RelativeSource={RelativeSource AncestorType=DataGridRow}}" />
<Setter Property="Foreground"
Value="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=DataGridRow}}" />
<Setter Property="BorderBrush"
Value="{Binding Path=BorderBrush, RelativeSource={RelativeSource AncestorType=DataGridRow}}" />
</Trigger>
</Style.Triggers>
</Style>