Represent a City in WPF
Say, I build a dynamic map in WPF.
I need to represent in this map locations(say, cities).
The representation of a city is simple: a dot (circle or image) and the text.
Both text and dot image are customizable.
What would you recommend using as a CityCont开发者_运维技巧rol in WPF?
Examples:- A UserControl having an
<Ellipse>
(or picture) and<TextBlock>
? - A CustomControl extending a
<TextBlock>
with a specific style? (is it possible to set the style inside this control) - ...something else?
Google something like "WPF UserControl vs CustomControl" and you'll get a whole list of articles pointing out the differences.
This one has a fairly simple explanation of the differences. You'll need to choose which one is best for your situation.
I would go for an Ellipse
, you can then define different properties such as color etc.
<CityControl>
<Ellipse>
<GeoInformation>
<TextBlock>
etc..
I would create a UserControl
.
It'd contain a Canvas
.
Inside the Canvas
, put a TextBlock
and a centered Ellipse
.
Add needed properties. First one can be degrees for text to position respect to ellipse center.
But that's just 1 idea. The possibilities are endless.
精彩评论