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, I have a class called 'Prompt' and a collection called 'PromptCollection', in the xoml file I have created a datatemplate<ComboBox DockPanel.Dock="Top" Name="cmbPrompt" SelectedValue="{Binding Value}" ItemsSource="{Binding Source={StaticResource PromptEntityCollection}}" SelectedValuePath="Name" DisplayMemberPath="Name"> the Type Editor I create is as follows <ms:TypeEditor EditedType="{x:Type boPrompt:Prompt}" EditorTemplate="{StaticResource PromptPopUpEditor}" />. The issue that I am having is when I select a value in the drop down, the property change event is not being raised to set the new value on the object itself. If I use a property editor and instead of using a Custom object but use a primitive type like a 'Guid' the property change event gets raised and the value gets set. Am I missing something with the TypeEditor so it can raise the event to set the property. Thanks, Justin |
|
|
Is Prompt a reference type (class) or value type (struct)? If Prompt is a reference type (class), the default behaviour of the TypeEditor is to pass the Prompt instance to the editor template as its data context. (See the PhoneNumber examples in the samples.) So the template is editing the properties of the existing Prompt instance. In your case, the combo box would be setting Prompt.Value. You can change this behavior by setting TypeEditor.TemplateBindingMode to WrappedValue. This will cause the TypeEditor to behave like a PropertyEditor, with a Value pseudo-property which changes the value of the Prompt property itself, to a different Prompt object. |
|
|
Prompt is a reference to a class type, would that effect anything? |
|
|
It depends what you are trying to achieve. If your TypeEditor is intended to edit the properties of the existing Prompt object -- i.e. to edit Prompt.Value -- then what you have should be working. If not, could you post or email a small repro project (please strip out all binaries first) so I can take a look? Thanks! If your TypeEditor is intended to change the value of the Prompt property itself, to refer to a new Prompt object -- i.e. if your ComboBox contains a collection of Prompt objects -- then you need to change the TemplateBindingMode to WrappedValue. This will cause the TypeEditor to behave more like a PropertyEditor, setting the Prompt property to a new value (a different Prompt object). |
|