2011-11-11 18 views
1

私はボタンとして使用している画像を持っていますが、マウスでは不透明度を100%にします。この時点では80%にすぎません。どうすればいい?ここ 画像の不透明度を100%に設定

が...私のマウスは、あなたのイベントは "ヒット" であると仮定してのSilverlight私はブレンドを使用しています

private void playButton_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) 
     { 
      double x; 


     } 

、イベント4つの 感謝

答えて

2

を入力している

private void playButton_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) 
{ 
    if (sender is Button) 
     ((Button)sender).Opacity = 1; 
} 

言いましたマウス出力イベントに応答して、不透明度を0.8に戻す必要があります。

でもこれを行うにはビジュアルステートマネージャを使用することができます。 here is a nice example on MSDN

2

XAMLでもすべてのことができます。これにはBlend SDK for Silverlight 4が必要です(実際にはブレンドが必要ないため、Expression Blendを使用していない場合や誤解しないでください)。

<UserControl x:Class="SilverlightApplication2.MainPage" 
    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" 
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
    xmlns:ei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" 
    mc:Ignorable="d"> 

    <Grid> 
     <Image Source="Penguins.jpg" Opacity="0.8"> 
      <i:Interaction.Triggers> 
       <i:EventTrigger EventName="MouseEnter"> 
        <ei:ChangePropertyAction PropertyName="Opacity" Value="1.0"/> 
       </i:EventTrigger> 
       <i:EventTrigger EventName="MouseLeave"> 
        <ei:ChangePropertyAction PropertyName="Opacity" Value="0.8"/> 
       </i:EventTrigger> 
      </i:Interaction.Triggers> 
     </Image> 
    </Grid> 
</UserControl> 
:あなたはこのような何かにそれを変換することができ

<UserControl x:Class="SilverlightApplication2.MainPage" 
    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> 
     <Image Source="Penguins.jpg" Opacity="0.8"/> 
    </Grid> 
</UserControl> 

:あなたのような何かを始めと仮定すると、

関連する問題