TextBox
たとえば、 「TextBoxStyleBase」のデフォルト スタイルがあるとします。次に、別の境界線の色を定義して、Base-styleDataGrid
という独自のTextBox
スタイル BasedOn を持つスタイルを定義します。
a 内のどこかでDataGrid
別のスタイルを定義したいのですTextBox
が、style で定義されたものから継承しDataGrid
ます。
現在の「コンテキスト」内の特定のコントロールに対して現在定義されているスタイルからスタイルを継承させる方法はありますか?
編集:
より明確にするために、ここに私が持っているものがあります:
<!-- explicit style for all TextBoxes -->
<Style TargetType="{x:Type TextBox}" x:Key="TextStyle">
<Setter Property="FontSize" Value="16"/>
</Style>
<!-- implicit style for all TextBoxes -->
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource TextStyle}"/>
<!-- DataGrid style changing inner TextBox style -->
<Style TargetType="{x:Type DataGrid}">
<Style.Resources>
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource TextStyle}">
<Setter Property="FontSize" Value="20"/>
</Style>
<!-- since TextBox has defined implicit style this would be equivalent to -->
<!--<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
<Setter Property="FontSize" Value="20"/>
</Style>-->
</Style.Resources>
</Style>
<Control>
<DataGrid>
<Row>
<TextBox/> <!-- should show as defined in DataGrid style -->
</Row>
<Row>
<Row.Resources>
<Style TargetType="{x:Type TextBox}" BasedOn=" ??? ">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="FontWeight" Value="Bold"/>
</Trigger>
</Style.Triggers>
</Style>
</Row.Resources>
<TextBox/> <!-- should show with additional trigger -->
</Row>
</DataGrid>
</Control>
BasedOn = '???' に何を入れるか テキストは FontSize 20 で表示されますが、ホバーすると太字になります。