Home Forums WPF controls Xceed DataGrid for WPF CellEditor Again

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

    May be i the last message wasn’t clear enough , i didn’t get any replies
    http://forums.xceed.com/forums/ShowPost.aspx?PostID=6372

    Simply :
    1- i want cell editor to have two controls not one
    – Button and textbox ( will contains the bytes of the browsen image )
    2- how to manage inserting data to be taken from the text of the textbox ( image bytes )

    Thx

    Imported from legacy forums. Posted by hesham (had 3954 views)

    Xceed Support
    Member
    Post count: 5658

    Hi,

    We did see your previous post, but we did not have time to answer yet.

    Nothing prevents your from placing any control in a CellEditor (or composition of controls). The only important thing is that in your CellEditor.EditTemplate (DataTemplate) you need to have “one” element which value is bound using the CellEditorBindingExtension ( “<myControl myProp=”{xcdg:CellEditorBinding}” /> ).

    How you develop this “control” or “template” is then really up to you, there is almost an infinite amount of ways in which you can achieve your goal.

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

    User (Old forums)
    Member
    Post count: 23064

    ya i know it can be done in different ways as you said in XAML
    but the problem is that i create the datagrid dynamically and any dealing with it is programatically

    if you plz could give me one way to do this using code 🙂 cuz am not familiar with XCEED datagrid as you are

    Thx

    Imported from legacy forums. Posted by hesham (had 352 views)

    Xceed Support
    Member
    Post count: 5658

    Unfortunalty, I do not have the time at the moment to develop a working sample of this kind…

    However, I can start you in the mysterious ways of building a DataTemplate through code (hoping that this will help you)…

    <hr>
    DataTemplate myCellEditTemplate = new DataTemplate();
    myCellEditTemplate.VisualTree = new FrameworkElementFactory(typeof(MyCustomImageEditor));

    CellEditorBindingExtension myBinding = new CellEditorBindingExtension();
    myCellEditTemplate.VisualTree.SetBinding( MyCustomImageEditor.ByteOutputProperty, myBinding.ProvideValue( null) );

    ControlTemplate myControlTemplate = new ControlTemplate(typeof(MyCustomImageEditor));
    myControlTemplate.VisualTree = new FrameworkElementFactory(typeof(StackPanel));

    //create a FrameworkElementFactory for the Control that will display the byte output… Bind it to the ByteOutput DP, and then…

    myControlTemplate.VisualTree.AppendChild( myImageControl);

    //create a FrameworkElementFactory for the Control that will allow selecting the image path… Bind it to the ImagePath DP, and then…

    myControlTemplate.VisualTree.AppendChild( myPathControl);

    myCellEditTemplate.VisualTree.SetValue( MyCustomImageEditor.TemplateProperty, myControlTemplate );

    //Note: this code was typed without verification of the syntax.. so it might not run, but the base should be good.
    <hr>
    This assumes that you would have created a control that has a ByteOutput DP and an ImagePath DP (and that changing the ImagePath property causes the ByteOutput value to change).

    That`s about as much as I can give you at the moment. I hope it will be enough for your needs.

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

    User (Old forums)
    Member
    Post count: 23064

    Thanks it was really usefull

    Now the situation is as follows :

    CellEditor cellEditor = new CellEditor();
    FrameworkElementFactory btn = new FrameworkElementFactory(typeof(Image));
    btn.AddHandler(Image.MouseDownEvent, new MouseButtonEventHandler
    (BrowsePicture_Click));
    cellEditor.EditTemplate = new DataTemplate();
    cellEditor.EditTemplate.VisualTree = new FrameworkElementFactory(typeof(StackPanel));
    cellEditor.EditTemplate.VisualTree.AppendChild(btn);
    column.CellEditor = cellEditor;

    and in BrowsePicture_Click I save the bytes of the image in Image.Tag Property
    Now how i bind the Tag property To be the value of the cell when it is inserted

    Thx in advance

    Imported from legacy forums. Posted by hesham (had 596 views)

    Xceed Support
    Member
    Post count: 5658

    the way to bind any property to the content of cell is by using the CellEditorBindingExtension class…

    You do so in XAML by:

    <Image Tag=”{xcdg:CellEditorBinding}”/>

    or in C# by:

    CellEditorBindingExtension cellEditorBinding = new CellEditorBindingExtension();
    myFrameworkElementFactory.SetBinding( Image.TagProperty, cellEditorBinding.ProvideValue(null));

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

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