1
我试图在Silverlight中为Windows嵌入样式控件来模拟一个选项卡控件。Silverlight的按钮样式
我已经开始使用这些按钮,造型它们看起来像标签项目。
我遇到的问题是我想要“活动”选项卡的概念,并从此更改活动选项卡项目颜色或更改非活动选项卡的颜色。我有一个想法,添加一个自定义的视觉状态'活跃'可能是一个选择,但我是silverlight的一个完整的新手,所以也许这是不正确的。
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" xmlns:local="clr-namespace:WindowsEmbeddedSilverlightApplication1"
x:Class="WindowsEmbeddedSilverlightApplication1.MainPage"
Width="800" Height="480">
<UserControl.Resources>
<Style x:Key="TabItemFirst" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="#FFC5EEFF" CornerRadius="5,5,0,0" BorderBrush="Black" BorderThickness="1">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TabItemNext" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="#C8E9F7" Margin="-1,0,0,0" CornerRadius="5,5,0,0" BorderBrush="Black" BorderThickness="1">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel Orientation="Horizontal">
<Button Canvas.ZIndex="3" Width="75" Height="25" Style="{StaticResource TabItemFirst}" Content="Left"/>
<Button Canvas.ZIndex="2" Width="75" Height="25" Style="{StaticResource TabItemNext}" Content="Center"/>
<Button Canvas.ZIndex="1" Width="75" Height="25" Style="{StaticResource TabItemNext}" Content="Right"/>
</StackPanel>
</Grid>
</UserControl>
有关如何实现此功能的任何指针都将非常感谢。
您好,感谢。查看ToggleButton样式xaml是有帮助的,但它不允许控件在单击另一个控件时保留状态。即。页面上无关的控件。我想我需要添加一个新的状态,并能够使用与每个标签项相关的这个值来知道它是否应该有不同的外观。 – antinutrino