[英]How to check if 3 Image controls have the same image source
I have 3 Image controls that are named: slot1, slot2 and slot3. 我有3个名为的图像控件:slot1,slot2和slot3。 If I want to check that slot1, slot2 and slot3 have the same image source, I do this:
如果要检查slot1,slot2和slot3是否具有相同的图像源,请执行以下操作:
if (slot1.Source == slot2.Source && slot2.Source == slot3.Source && slot3.Source == slot1.Source)
{
MessageBox.Show("sss");
}
But it doesn't show me the message box. 但这并没有显示消息框。 I tried different methods but they didn't show the message box too.
我尝试了不同的方法,但它们也没有显示消息框。 What did I do wrong?
我做错了什么?
I put
Console.WriteLine(slot1.Source)
and same for all slots and it showed"pack://application:,,,/Anime Clicker;component/Images/heroFaceImages/GohanFace.png"
3 times我将
Console.WriteLine(slot1.Source)
和所有插槽都放置相同,它显示"pack://application:,,,/Anime Clicker;component/Images/heroFaceImages/GohanFace.png"
3次
Compare the string representations then: 然后比较字符串表示形式:
if (slot1.Source != null && slot2.Source != null && slot3.Source != null
&& slot1.Source.ToString() == slot2.Source.ToString()
&& slot2.Source.ToString() == slot3.Source.ToString())
{
MessageBox.Show("sss");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.