tags:

views:

88

answers:

2

I have a Silverlight app that adds a Path to the LayoutRoot grid of a UserControl. The path geometry is a simple rectangle.

I would like to be able to add a TextBlock that is contained within the Path that was added to the LayoutRoot grid.

I am also using a custom Adorner to allow me to resize the Path on the screen and move it around.

Basically, I want the TextBlock's parent to be the path, so that whenever I move the Path around, the TextBlock moves with it, and, also, the text within the TextBlock can never go outside the boundaries of the Path.

Here is an example of what I currently have:

var shape = new ShapeClass((o, u) => { LayoutRoot.Children.Add(o); LayoutRoot.Children.Add(u); }); 

Here is the constructor for the Shape class:

public ShapeClass(Action<Path, TextBlock> insert){}

Where 'o' is the Path object and 'u' is the TextBlock...

Does anyone have any ideas as to how this might be achieved?

Thanks.

+1  A: 

Put both the path and the textbox into a Grid or canvas, and move that instead. That way the two controls will stay in the same position relative to each other.

Guy
Ok - that will resolve that issue - but the Path geometry can be in the form of a rectangle, as mentioned in my original post, or, it could be in the form of a diamond. In the case of a diamond, if I have a grid that I add both the path and textblock to, and I am using textwrapping for the textblock, how would I ensure that the text within the textblock stays within the boundaries of the path that is a diamond?
Chris
A: 

A Path is not a Content control hence you cannot place a TextBox within it.

If you are using a simple Rectangle then why not use a Border control instead?

AnthonyWJones