0
我正在創建一個自定義Silverlight按鈕。由於我想獲得視覺狀態,我不想使用樣式或控件模板。所以,我寫這樣的:在不使用樣式的情況下在Silverlight中創建自定義按鈕
<Button x:Class="MyNameSpace.MyImageButton"
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">
<Grid x:name="LayoutRoot">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup ...
</VisualStateGroup>
<VisualStateManager.VisualStateGroups>
<Border (Various border styles)
<StackPanel x:Name="ContentPresenter" Orientation="Horizontal">
<Image Source="{Binding Path=this.ImageSource}" Stretch="Fill" />
<!--ContentPresenter-->
<ContentPresenter HorizontalAlignment="{Binding Path=this.HorizontalContentAlignment}"
VerticalAlignment="{Binding Path=this.VerticalContentAlignment}" >
<TextBlock Text="{Binding Path=this.Content}" />
</ContentPresenter>
</StackPanel>
</Border>
</Grid>
<Button.BorderBrush>
.....
<Button.BorderBrush>
</Button>
但是造型似乎並不奏效。它顯示默認的按鈕樣式。如何使它工作。我還註冊了一個圖像源屬性。這似乎也不起作用。
請幫忙。提前致謝。
如果您有任何關於此的信息,請對此評論。 –