1
我試圖在懸停時創建帶有發光效果的功能區菜單。在WPF Ribbon Button中可以嗎?像這樣http://tympanus.net/Development/IconHoverEffects/#set-8WPF功能區按鈕鼠標移動時發光效果
如果是的話是否有人知道如何?謝謝。
這是我到目前爲止。
<pbwpf:Window.Resources>
<Style TargetType="{x:Type my:Ribbon}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type my:Ribbon}">
<StackPanel Orientation="Vertical" Height="750" Background="#171f22">
<my:RibbonButton Name="rb_edit" Label="Edit" Margin="0,20,0,0">
<Button.Template>
<ControlTemplate>
<Border VerticalAlignment="Center" HorizontalAlignment="Center">
<Image Source="Images/rb_add4.png" Width="43" Height="43" />
</Border>
</ControlTemplate>
</Button.Template>
</my:RibbonButton>
<my:RibbonButton Name="rb_save" Label="Save" Margin="0,20,0,0">
<Button.Template>
<ControlTemplate>
<Border VerticalAlignment="Center" HorizontalAlignment="Center">
<Image Source="Images/rb_add4.png" Width="43" Height="43" />
</Border>
</ControlTemplate>
</Button.Template>
</my:RibbonButton>
<my:RibbonButton Name="rb_abort" Label="Abort" Margin="0,20,0,0">
<Button.Template>
<ControlTemplate>
<Border VerticalAlignment="Center" HorizontalAlignment="Center">
<Image Source="Images/rb_add4.png" Width="43" Height="43"></Image>
</Border>
</ControlTemplate>
</Button.Template>
</my:RibbonButton>
<my:RibbonButton Name="rb_delete" Label="Delete" Margin="0,20,0,0">
<Button.Template>
<ControlTemplate>
<Border VerticalAlignment="Center" HorizontalAlignment="Center">
<Image Source="Images/rb_add4.png" Width="43" Height="43"></Image>
</Border>
</ControlTemplate>
</Button.Template>
</my:RibbonButton>
<my:RibbonButton Name="rb_search" Label="Search" Margin="0,20,0,0">
<Button.Template>
<ControlTemplate>
<Border VerticalAlignment="Center" HorizontalAlignment="Center">
<Image Source="Images/rb_add4.png" Width="43" Height="43"></Image>
</Border>
</ControlTemplate>
</Button.Template>
</my:RibbonButton>
<my:RibbonButton Name="rb_print" Label="Print" Margin="0,20,0,0">
<Button.Template>
<ControlTemplate>
<Border VerticalAlignment="Center" HorizontalAlignment="Center">
<Image Source="Images/rb_add4.png" Width="43" Height="43"></Image>
</Border>
</ControlTemplate>
</Button.Template>
</my:RibbonButton>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="Label">
<Setter Property="FontFamily" Value="Lubalin" />
<Setter Property="Foreground" Value="#338e8f" />
<Setter Property="FontSize" Value="18" />
<!--<Setter Property="Opacity" Value="0.2" />-->
</Style>
</pbwpf:Window.Resources>
<Grid>
<Border BorderBrush="#9ac3cb" BorderThickness="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="55" />
<RowDefinition Height="745" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="55" />
<ColumnDefinition Width="969" />
</Grid.ColumnDefinitions>
<Border Name="bms" Grid.Row="0" Grid.Column="0" Background="#3fb5af">
<Label Name="lbl_bms" Content="BMS " VerticalAlignment="Center" HorizontalAlignment="Center" />
</Border>
<Border Name="header" Grid.Row="0" Grid.Column="1" Background="#ecf0f1" BorderBrush="Gray" BorderThickness="0,0,0,1"></Border>
<Border Name="btn_clse" Grid.Row="0" Grid.Column="1" Background="#ecf0f1" HorizontalAlignment="Right" BorderBrush="Gray" BorderThickness="0,0,0,1">
<Image Source="Images/c_lose.png" Height="40" Width="40"></Image>
</Border>
<pbwpf:StaticText Grid.Row="0" Grid.Column="1" Height="21" HorizontalAlignment="Left" Margin="10,20,0,0" Name="st_dte" Text="Main Form" TextSize="-10" VerticalAlignment="Top" Width="88" PBHeight="84" PBWidth="402" X="46" Y="80" />
<Border Name="sidebar" Grid.Row="1" Grid.Column="0" Background="#171e24">
<StackPanel VerticalAlignment="Top" Orientation="Vertical" HorizontalAlignment="Left">
<my:Ribbon Height="745" Name="ribbon1" TabIndex="10" Width="55">
<my:Ribbon.ApplicationMenu>
<my:RibbonApplicationMenu Visibility="Collapsed" />
</my:Ribbon.ApplicationMenu>
</my:Ribbon>
</StackPanel>
</Border>
<Border Grid.Row="1" Grid.Column="1">
<!--<pbwpf:MDIClient Name="mdi1" Background="white"></pbwpf:MDIClient>-->
</Border>
</Grid>
</Border>
</Grid>
下面是我想要實現的樣式的屏幕截圖。
嗨@pushpraj謝謝你!這是我正在尋找的。你太好了!!非常感謝你。我會將此標記爲答案!再次感謝。 – 2014-09-03 07:44:32
嗨!另一個問題。 WPF Ribbon中可能會產生效果嗎?謝謝! – 2014-09-03 07:57:02
是的,這確實是可能的。你可以給我一個鏈接到你正在使用的圖書館,我可以試一試。同時,您可以將樣式的目標類型更改爲功能區按鈕,並查看是否符合要求,您可以根據需要調整模板。 – pushpraj 2014-09-03 11:51:31