Silverlight+XNA を使用して WP7 アプリを作成しています。その中で、ボタンの背景 (Silverlight 要素) として画像を使用しており、ボタンを押すたびに白い背景が表示されます。どうすればそれを取り除くことができますか? ボタンのデフォルトのプロパティのようです。
質問する
2094 次
4 に答える
3
ボタンの ClickMode を Press に設定すると、効果が無効になります
<Style TargetType="Button">
<Setter Property="ClickMode" Value="Press"/>
</Style>
于 2012-09-10T04:32:27.013 に答える
1
この質問には既存のスレッドがいくつかあります。
@thongadukaが提案した方法で、これを実装しました。以下の完全な実装を確認してください。
<StackPanel Height="auto" HorizontalAlignment="Left" Margin="0,0,0,0" Name="stackPanel1" VerticalAlignment="Top" Width="auto" >
<StackPanel.Resources>
<Style x:Key="ButtonTemplate_ok" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00" Storyboard.TargetProperty="Background" Storyboard.TargetName="hoverbutton">
<DiscreteObjectKeyFrame KeyTime="00:00:00">
<DiscreteObjectKeyFrame.Value>
<ImageBrush ImageSource="/StickGameSlX;component/Images/buttons/ok_pressed.png"/>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused"/>
<VisualState x:Name="Unfocused"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="hoverbutton">
<Border.Background>
<ImageBrush ImageSource="/StickGameSlX;component/Images/buttons/ok_unpressed.png"/>
</Border.Background>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</StackPanel.Resources>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" >
<Button Style="{StaticResource ButtonTemplate_ok}" Content="OK" HorizontalAlignment="Center" Margin="546,296,198,130" Name="button1" VerticalAlignment="Center" Click="button1_Click" Width="57" Height="53" BorderBrush="White" Foreground="Black"/>
</Grid>
</StackPanel>
于 2012-07-03T05:26:29.700 に答える
0
ボタンのスタイルを作成する必要があります。各表示状態のボタンのプロパティを変更します。押された状態、通常の状態などのさまざまな状態の背景画像のプロパティを設定するように。そして、そのスタイルをボタンに適用します。Microsoft Expression Blend は、いくつかの簡単な手順でそれを行うのに役立ちます。
于 2012-05-07T05:34:16.410 に答える
0
ボタンのスタイルを編集するには、エクスプレッション ブレンドを使用する必要があります。たとえば、ボタンが押された状態のときに、背景または境界ブラシを編集できます。
于 2012-05-07T06:37:12.830 に答える