Home Forums WPF controls Xceed DataGrid for WPF HowTo change the CellEditor from a column programmatically

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #23476 |

    Hi,

    I need assign the CellEditor from a Column programmatically in runtime with C#. This is what I tried:

    Binding bInterneBez = new Binding(“InterneBezeichnung”);
    Column colInterneBez = new Column(“InterneBezeichnung”, “InterneBezeichnung”, bInterneBez);
    colInterneBez.CellEditor = new CellEditor();
    colInterneBez.CellEditor.EditTemplate = new DataTemplate(typeof(ComboBox));
    DataTemplate dt = new DataTemplate(typeof(ComboBox));

    I can only pass the type of the CellEditor to the DataTemplate but no further information. How would I realize the example in your documentation from the CellEditor Class? How do i just get a ComboBox instead of the TextEditor in the Column?

    Thanks in advance
    Silas

    Imported from legacy forums. Posted by Ralf (had 2963 views)

    User (Old forums)
    Member
    Post count: 23064

    For the community (got the answer from Xceed by mail)… Basically this is how it can be done:

    DataTemplate template = new DataTemplate();
    FrameworkElementFactory factory = new FrameworkElementFactory( typeof( ComboBox ) );

    template.VisualTree = factory;

    CellEditor.EditTemplate = template;

    cheers
    Silas

    Imported from legacy forums. Posted by Ralf (had 426 views)

    User (Old forums)
    Member
    Post count: 23064

    I’ve used this type of method but the problem is that it does not bind correctly to grid…the drop down shows but it does not update the grid column to the newly selected value and the drop initially show up blank.

    I set my data source using the following:

    comboBoxFactory.SetValue(ComboBox.ItemsSourceProperty, ((App)Application.Current).Statuses);
    comboBoxFactory.SetValue(ComboBox.DisplayMemberPathProperty, “Status”);

    not sure how to setup so the the combo updates parent column…any ideas?

    Imported from legacy forums. Posted by Adrian (had 427 views)

    Xceed Support
    Member
    Post count: 5658

    You have to use a CellEditorBindingExtension to bind a CellEditor to the Cell’s value.

    refer to this post for details:
    http://forums.xceed.com/forums/ShowPost.aspx?PostID=7110

    Imported from legacy forums. Posted by Marcus [Xceed] (had 3863 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.