开发者

How can i create a Point Object in XAML?

there is a Line开发者_运维问答 control which we can define like this:

<Line X1="10" Y1="30" X2="100" Y2="100" Stroke="Red" />

I'd like to create a point object of which i could define like this

<my:Point X="12" Y="44" Fill="Red" />

the whole point of this is that i could avoid calling Canvas.Top and Canvas.Left methods anyone have any ideas?


If there is a Point class in the namespace referred to by the XML namespace my, and it has settable properties named X, Y and Fill of a compatible type, then instantiating an object in XAML is as simple as your example.

Of course you may need to convert from the string "Red" to a Brush, but that's easy.

The more interesting question is how exactly do you want to use that object?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜