2011-12-05 85 views
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> 

有關如何實現此功能的任何指針都將非常感謝。

回答