Hi,
I have custom value editor for field and I would like to automatically fit column width to content when field enters Edit mode, because my value editor is much wider in Edit mode and user cannot see its content until he manually extends column width.
Sample project attached. Simply try to edit value in the second column.
Hello,
Thank you for your post. I have been looking into it and I modified it, so now it works as you want. Please let me know if this is what you want to achieve or you need further clarifications on this matter.
Looking forward for your reply.
It looks like it really works, but I wonder what these lines of code do:
private void dataGrid_EditModeStarted(object sender, EditModeStartedEventArgs e)
{
string tmp = e.Editor.Text;
e.Editor.Text += "d";
e.Editor.Text = tmp;
}
Is there a more standard way to make it work? Changing Text property apparently raises some event which triggers column width recalculation. Maybe we can trigger recalculation more directly?
I have been looking into your post and I can say that the reason I did this Editor’s Text change manually is because the method that re-renders the Width of the CellValuePresenter is not exposed and cannot be used. Please let me know if this helps you or you need further clarifications on this matter.
Thanks Stefan.
I've used your approach and it works ;)
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.