在wpf的wb:InputVerifyWodowBase范围内修改title背景颜色
时间: 2024-05-06 16:22:04 浏览: 9
您可以使用以下代码在InputVerifyWodowBase中修改标题栏的背景颜色:
```xaml
<Style TargetType="{x:Type local:InputVerifyWodowBase}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:InputVerifyWodowBase}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border x:Name="PART_TitleBar"
Grid.Row="0"
Background="Red" <!-- 修改此处的颜色 -->
Height="32"
BorderThickness="0,0,0,1"
BorderBrush="{StaticResource WindowBorderBrush}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Image x:Name="PART_Icon"
Grid.Column="0"
Source="{TemplateBinding Icon}"
Margin="2"/>
<TextBlock x:Name="PART_Title"
Grid.Column="1"
Text="{TemplateBinding Title}"
VerticalAlignment="Center"
Margin="2"/>
<Button x:Name="PART_CloseButton"
Grid.Column="2"
Style="{StaticResource WindowCloseButtonStyle}"
Command="{Binding CloseCommand, RelativeSource={RelativeSource TemplatedParent}}"
ToolTip="Close"/>
</Grid>
</Border>
<ContentPresenter x:Name="PART_ContentPresenter"
Grid.Row="1"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
```
在上面的代码中,找到名为“PART_TitleBar”的Border元素,并将其背景颜色更改为所需的颜色即可。