我正在尝试制作一个带圆角的简单进度条.
这是我的xaml:
<Grid>
<ProgressBar Minimum="0" Maximum="100" Height="50" Value="50" Name="pbStatus" BorderBrush="Black" BorderThickness="3" Foreground="#336699" />
<TextBlock Text="{Binding ElementName=pbStatus, Path=Value, StringFormat={}{0:0}%}" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
Run Code Online (Sandbox Code Playgroud)
我正在寻找Border-Radius房产....但我找到它.有什么帮助吗?
谢谢.
我在网上搜索带圆角的TextBox,并找到如下的xaml代码:
<Style TargetType="{x:Type my1:CustomTextBox}">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate >
<Border Background="{TemplateBinding Background}" x:Name="Bd"
BorderThickness="2" CornerRadius="5" BorderBrush="#FFF9EAB6">
***<ScrollViewer x:Name="PART_ContentHost" />***
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="#FFC7B0B0"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="#FFC7B0B0"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="False">
<Setter Property="Foreground" Value="#FFC7B0B0"/>
</Trigger>
<Trigger Property="Width" Value="Auto">
<Setter Property="MinWidth" Value="120"/>
</Trigger>
<Trigger Property="Height" Value="Auto">
<Setter Property="MinHeight" Value="27"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
我想知道是什么
<ScrollViewer x:Name="PART_ContentHost" />
Run Code Online (Sandbox Code Playgroud)
详细说明为什么不正确地工作我的模板如果从中删除这一行,请详细告诉我.
非常感谢.
我在我的应用程序中有TextBlocks和Comboboxes我希望Textblock前景为白色,Combobox前景为Black.
我尝试的是:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="White" />
</Style>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="Foreground" Value="Red" />
</Style>
</ResourceDictionary>
<Grid Background="Black">
<TextBlock Height="23" HorizontalAlignment="Left" Margin="27,30,0,0" Name="textBlock1" Text="TextBlock" VerticalAlignment="Top" />
<ComboBox Height="23" HorizontalAlignment="Left" Margin="12,99,0,0" Name="comboBox1" VerticalAlignment="Top" Width="120" />
</Grid>
Run Code Online (Sandbox Code Playgroud)
但是组合框前景仍然是白色如何覆盖组合框中的TextBlock前景?(在CSS中这很容易,但在WPF中不知道)
如果我删除TextBlock的样式,其他所有内容都会改变,但是当我把样式放回去时,每个前景都是白色的.