I have subclassed a text editor in order to encapsulate the presence of a ButtonsRight with custom drop down control.
My subclassed editor and the control share a ViewModel. An IEditorDataFilter is provided to translate between the text representation in the text editor portion of the edtior control and the data shown in the custom control drop down.
So far I have been unable to figure out how to make the TextEditor re-run the EditorToDisplay conversion when changes are made in the drop down control.
My attempt so far has been to capture the INotifyPropertyChanged events that are raised by the ViewModel and convert them to edtior property changed events with the following code.
OnPropertyChanged(new PropertyChangedEventArgs(new PropChangeInfo(this, PropertyID.Value, null)));
This does not work, but I can't figure out what I would need to do to make the editor re-run the data filter.
Regards,
Mark
Generally speaking the IEditorDataFilter interface was not designed to accommodate manually triggering the conversions, but rather to give you a way to intercept the passing of data between the editor and owner during the normal course of operations.
By default UltraComboEditor (closest analog to what you have going on here) triggers the EditorToDisplay conversion by updating the textbox contents when (for example) the user selects an item from the list. Since you are presumably already doing this manually, I don't think you have anything to gain by going through that interface. Simply setting the UltraTextEditor's Text property when the dropdown closes is basically the equivalent of the IEditorDataFilter's EditorToDisplay conversion., at least for a dropdown-like control.
i gave this a try, but the text is not updating in the edit box, despite the fact that I am setting it.
in my handling of my ViewModels property changed event I am doing the following
this.Text = ViewModel.ToString(); with no joy.
where "this" is my subclassed UltraTextEditor.
the text of the editor remains empty.
I think you probably should set the Value rather than the text. But this might not update the display while the control is in edit mode.
If setting the Value doesn't work, then I recommend that you set the Text directly on the TextBox which is contained by the UltraTextEditor. Something like:
TextBox textbox = this.Controls[0] as TextBox
if (textBox != null)
texbox.Text = ViewModel.ToString();
I was hopeful when I saw your reply, but somehow there are no child controls of the ultratexteditor, at least it seems while in edit mode.
That's not possible. If UltraTextEditor is in edit mode, there has to be a control in it's Controls collection. This control will only be there when the control is in edit mode, though. That means that it has focus and there's a blinking caret in the control. Or, you can set AlwaysInEditMode to true so that it stays in edit mode all the time.
I could get a textbox by casting the Editor property of the UltraTextEditor to an EditorWithText, then getting the textbox from there.
In edit mode though, the controls collection was empty.
Is the control "InEditMode" when the user clicks on one of the buttons right (which is set as a drop down button with custom control)?
MarkAllanson said:Is the control "InEditMode" when the user clicks on one of the buttons right (which is set as a drop down button with custom control)?
I'm pretty sure it does. But you can check the IsInEditMode property to be sure.