Click to edit in Silverlight

Is there a way to click to edit in Silverlight? I have some items that will be displayed in the treeview control, and I would like the tags to be editable directly in the tree structure.

Does anyone know how to do this?

+5
source share
1 answer

Very simple. I have implemented many forms with such an exchange mechanism.

You can do this with the converter and make a simple BooleanToVisibility conversion in the IsEditable property that exists on the objects that you attach to your TreeView. Inside the TreeView, the ItemTemplate simply binds the TextBlock so that it is reset whenever the IsEditable property is true and binds the TextBox so that it is arranged when the IsEditable property is false (and vice versa).

If you want to create a ClickToEdit user control, you will need to do the following:

  • Create a class that inherits from ContentControl
  • Derive new dependency properties of the DataTemplate: one type called EditableTemplate.
  • Add a MouseLeftButtonUp event handler inside your OnApplyTemplate to listen for the click.
  • EditableTemplate click.
  • , .

, TreeView:

  • ItemTemplate TreeView
  • ClickToEdit

( ) , . , NumericUpDown DateTimePicker, TextBox.

DataForm Silverlight 3. , .

+9

All Articles