0
我想創建一個帶圓形右上角和下角的平面按鈕。此按鈕需要在點擊和鼠標懸停後更改背景。專注於標籤,文本塊和邊框
目前我標記看起來是這樣的:
<Border x:Name="MyButton" Height="25" Margin="0,5,0,0" CornerRadius="0 5 5 0" BorderThickness="1" BorderBrush="Gray" Style="{StaticResource myStyle1}">
<StackPanel Orientation="Horizontal" Margin="8,0,0,0">
<Image Source="image.jpg" Height="20"/>
<TextBlock Text="My Button"/> <!-- Could also be a label if needs to be. -->
</StackPanel>
</Border>
<Style x:Key="myStyle1" TargetType="{x:Type Border}">
<Setter Property="Background" Value="{StaticResource MainContentForegroundColor}"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
在觸發鼠標完美的作品,但我不能讓點擊觸發工作...我已經試過IsKeyboardFocusWithin
和IsFocused
但事與願違工作。
我有一個按鈕,另一個模板,現在我想爲它創建一個特殊的按鈕,我可以設置「單用戶控件模式「的財產,它會改變風格approriately。我應該怎麼做?例如, ... –
Sys
2010-07-28 11:50:07
No只需創建一個名爲「ButtonStyle2 「爲新模板,並參考使用Style =」{DynamicResource ButtonStyle2}「 – Ragunathan 2010-07-28 11:57:13