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.
Select the Text tool on the Tool bar. Place the Text tool on the path and click once. The mouse pointer will take on the Text I-beam shape and a flashing line will appear on the path along with small X. The small illustration below approximates what you will see.
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.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With