Hi,
I am trying to use values i declare inside a UserControl class to change things inside the SurfaceWindow class. Now what i know so far is that i have to use a DependencyProperty to get the value from the UserControl and then put it inside a public string.
public string MapValue
{
get { return (string)GetValue(MapValueProperty); }
set { SetValue(MapValueProperty, value); }
}
public static readonly
DependencyProperty MapValueProperty = DependencyProperty.Register("MapValue", typeof(string), typeof(MapManager));
Now my question is, how do i bind the public string (that is inside the UserControl) to a element (inside the SurfaceWindow)?
If i use the DependencyProperty do i make a new class or do i put it in the usercontrol code?
I would be very happy if someone could help me with this problem..
-
As far as i can tell you are trying to bind to a dependency property of some control in your window.
If this is the case you could use the ElementName syntax in the binding declarations such as:
<TextBlock Text="{Binding ElementName=MapControl, Path=MapValue}"/> -
I had already have this inside my window control:
<Image x:Name="iGroundPlan" Source="{Binding ElementName=MapManager,Path=MapValue}" />(MapManager is the name of my usercontrol)
But looks like it aint working, and i dont know why.. Its like the windows never knows when the value MapValue is updated in my usercontrol =\
Entrodus : 1. How do you update the Mapvalue? Give us an example. (could be a Mode=Twoway issue) 2. Is it a valid Image? Try using a textblock just to see what the actual value is, and whether it gets updated or not.
0 comments:
Post a Comment