C#WPF代码再大一点.............. [英] C# WPF code greater then.............
本文介绍了C#WPF代码再大一点..............的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码
this is my code
if (view.Margin == new Thickness(view.Margin.Top > 0, -1, 0, 0))
{
//code in here
}
可以请一个人解释为什么这行不通吗,请告诉我另一个我可以做到这一点?
我收到这些错误
can some one please explain why this isn''t working and please tell me another that i can do this?
I get these errors
Error 2 Argument 1: cannot convert from 'bool' to 'double' C:\Users\Kyle\documents\visual studio 2010\Projects\Project Hat\Project Hat\MainGame.xaml.cs 33 46 Project Hat
Error 1 The best overloaded method match for ''System.Windows.Thickness.Thickness(double, double, double, double)'' has some invalid arguments C:\Users\Kyle\documents\visual studio 2010\Projects\Project Hat\Project Hat\MainGame.xaml.cs 33 32 Project Hat
推荐答案
view.Margin.Top > 0
是布尔值.
Thickness
构造函数仅接受double
.
传递布尔值没有任何意义.您到底想达到什么目的?
view.Margin.Top > 0
is a boolean.
TheThickness
constructor acceptsdouble
only.
Passing a boolean doesn''t make sense. What exactly are you trying to achieve?
尝试三元运算符
Try ternary operator
new Thickness(view.Margin.Top>0?1:0, -1, 0, 0)
这篇关于C#WPF代码再大一点..............的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文