This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi Is it possible to embed a user control as a custom field in the property grid? I am trying to illustrate my problem this in the attached VS 2008 solution. The usercontrol is embeding properly, but databinding does not seem to work inside the embedded user control. I have illustrated this problem by putting a label on the userControl and trying to bind it to the DataContext property: <Label Content="{Binding MyProperty}" ....
|
|
|
In a PropertyEditor template, the DataContext is *not* the value of the edited property. (Because the edited property is typically an immutable value like an int or string, so if that were the DataContext we wouldn't be able to propagate changes back to the source property.) Instead, it's a little wrapper class. You get at the value via the Value of the DataContext: {Binding Value}. In your case, you want the DataContext of the EmbeddedView to be the property value (an object of type Embedded), not the little wrapper class. So you just need to be explicit about this in your editor template: <DataTemplate x:Key="EmbeddedTemplate" DataType="{x:Type vm:EmbeddedVM}"> With that change, your example works for me -- the user control displays the Embedded.MyProperty value as desired. |
|
|
Thank you! It works great :) |
|