如何通过右键单击更改图像的可见性 [英] how to change visibility of Image with right click
本文介绍了如何通过右键单击更改图像的可见性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个图片.
我的XAMl代码:
I have two Images.
My XAMl code:
<Image Height="13" HorizontalAlignment="Left" Margin="284,236,0,0" Name="CBoff2" Stretch="Fill" VerticalAlignment="Top" Width="18" Source="/ConfigurationWindowsDemo;component/Images/SymbolsOFF1.jpg"/>
<Image Height="13" HorizontalAlignment="Left" Margin="284,236,0,0" Name="CB2" Stretch="Fill" VerticalAlignment="Top" Width="18" Source="/ConfigurationWindowsDemo;component/Images/SymbolsON.jpg" />
我要的是当我们右键单击"CB2"时,"CBoff2"应该可见,反之亦然.
What I Want is when we right click to "CB2", "CBoff2" should be visible and vice Versa. How can we do that?
推荐答案
<Image MouseRightButtonDown="image1_MouseRightButtonDown" Source="Sunset.jpg" Grid.Row="2" Margin="156,141,0,55" Name="image1" Stretch="Fill" HorizontalAlignment="Left" Width="139.83" />
该处理程序将禁用image2.
The handler will disable the image2.
private void image1_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
image2.Visibility = Visibility.Hidden;
}
但是,当另一个图像被隐藏时,您将如何做呢?
But how are you going to do vice-versa when the other image gets hidden.
我在图像控件中看不到任何事件处理程序.
您需要添加一个.
I don''t see any event handler in your image control.
You need to add one.
这篇关于如何通过右键单击更改图像的可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文