控制边距属性取决于wpf中的另一个控制边距属性

控制边距属性取决于wpf中的另一个控制边距属性

本文介绍了控制边距属性取决于wpf中的另一个控制边距属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图以这种方式在wpf应用程序的网格中显示两个画布控件. second_canvas.margin.left first_canvas.margin.right 相同.但这不能完成,因为margin属性不能用作变量.所以我尝试了"厚度".但是我不能将 first_canvas.margin.right 转换为 thickness 变量,因为它是 double 类型.那么,对此有什么解决方法吗?

I'm trying to show two canvas control in a grid in my wpf applike this way. the second_canvas.margin.left will be the same as first_canvas.margin.right .but it can't be done since margin property can't be used as a variable.So I tried "Thickness". but I can't convert first_canvas.margin.right to a thickness variable since it's a double type. So is there any work around for this?

推荐答案

我就是这样实现的...

I implemented it simply this way...

int right = system.convert.ToInt32(first_canvas.margin.right)
second_canvas.margin = new thickness(left = right)

这篇关于控制边距属性取决于wpf中的另一个控制边距属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 17:25