2011-08-16 7 views
0

私はこの回答を全部検索し、多くのスレッドを無駄に読んでいます。WPFボタンの不自然なフォーカス動作

これはVS10、.Net 4.0の標準ボタンで、背景とテキストとしてのイメージです。私は非本質的な特性を取り除いた。マウスがボタンに入ると、イメージは真ん中にテキスト(「Shop」)がある大きな灰色の長方形で置き換えられ上書きされます。

私はほとんどのプロパティを変更しようとしました。 FocusVisualStyleをStyleおよびnullに設定します。

アイデア?任意の入力のための


<Button 
    BorderThickness="0" Content="Shop" Focusable="False" 
    Foreground="Black" Name="buttonShop" OverridesDefaultStyle="False" 
    Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" 
    ClickMode="Release" IsEnabled="True" 
    IsHitTestVisible="True" isManipulationEnabled="True">     
<Button.Background> 
    ImageBrush ImageSource="/button-green.png" 
</Button.Background> 
</Button> 

感謝。

答えて

0

あなたの問題は、あなたが

が、これは

<Button .......> 
    <Image Source ...... /> 
</Button> 
+0

はい、thiボタンは1つのコンテンツのみを持つことができます。その中にはテキストが必要です。 – MikeL

0

あなたはこの

<Button> 
    <Button.Background> 
    <ImageBrush ImageSource="Images/exemple.ico"> 
    </ImageBrush> 
    </Button.Background> 
</Button> 
0

を指定して試すことができますしてみてください画像に背景を設定することであるToolBar.ButtonStyleKey別途

<Style x:Key="{x:Static ToolBar.ButtonStyleKey}" TargetType="Button"> 
    <Setter Property="Foreground" Value="Blue"/> 
    <Setter Property="FontSize" Value="14"/> 
    <Setter Property="HorizontalAlignment" Value="Center"/> 
    <Setter Property="VerticalAlignment" Value="Center"/> 
</Style> 
関連する問題