Home Forums WPF controls Xceed DataGrid for WPF CellEditorBinding can’t find binding path

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

    I have a cell whose content is bound correctly with this cell content template, but the cell editor template following it isn’t getting the same or correct binding path.

    <!–static & dynamic Cell DataTemplate–>
    <DataTemplate x:Key=”AmountCellTemplate”>
    <StackPanel Orientation=”Vertical” >
    <TextBlock Text=”{Binding Path=Static.Amount/>
    <TextBlock Text=”{Binding Path=Dynamic.Amount/>
    </StackPanel>
    </DataTemplate>

    <!–static and dynamic amount CellEditor template–>
    <xcdg:CellEditor x:Key=”AmountCellEditor”>
    <xcdg:CellEditor.EditTemplate>
    <DataTemplate>
    <StackPanel Orientation=”Vertical” >
    <TextBox Text=”{xcdg:CellEditorBinding}” Tag=”{Binding Path=Static.Amount}” />
    <TextBox Text=”{xcdg:CellEditorBinding}” Tag=”{Binding Path=Dynamic.Amount}” />
    </StackPanel>
    </DataTemplate>
    </xcdg:CellEditor.EditTemplate>
    </xcdg:CellEditor>
    </UserControl.Resources>

    There were no properties of CellEditorBinding I could find to specify the binding path. I tried using the Tag as you can see, but that didn’t work.

    What aspect of cell editor binding am I missing to get it to bind to right path correctly?

    thanks,
    sfairbanks

    Imported from legacy forums. Posted by Shelley (had 11217 views)

    User (Old forums)
    Member
    Post count: 23064

    I am still hoping to get a response to this, the error that is appearing in the output window is…

    “System.Windows.Data Error: 12 : Cannot get ‘DistinctValues’ value (type ‘ICollection’) from ‘ParentColumn’ (type ‘Column’). BindingExpression:Path=ParentColumn.DistinctValues.Count; DataItem=’ColumnManagerCell’ (Name=”); target element is ‘ColumnManagerCell’ (Name=”); target property is ‘NoTarget’ (type ‘Object’) TargetInvocationException:’System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.NotSupportedException: Automatic filtering can only be used if the grid’s data source is a DataGridCollectionView or DataGridCollectionViewSource.”

    Any suggestions would be appreciated.
    Thanks.

    Imported from legacy forums. Posted by Shelley (had 771 views)

    User (Old forums)
    Member
    Post count: 23064

    what is your data structure? can u post a bit more detail?

    Imported from legacy forums. Posted by nat (had 2187 views)

    User (Old forums)
    Member
    Post count: 23064

    btw, you should try to use dummy binding/converter to debug into why the data is not coming properly…
    http://marlongrech.wordpress.com/2007/12/18/debugging-wpf-databinding/

    Imported from legacy forums. Posted by nat (had 1753 views)

    User (Old forums)
    Member
    Post count: 23064

    I have tried using a dummy converter, only the cell content template will direct the data to the converter.

    The data I’m trying to bind are 2 amount values (double), Left.Static.Amount and Left.Dynamic.Amount. I’m trying to bind them to a single cell formated as a vertical stackpanel, the Column FieldName = “Left”. So I need the Binding path to be Static.Amount and Dynamic.Amount.

    The CellContentTemplate allows binding to this path, so the right amounts appear in the cells correctly, however the CellEditorBinding or CellEditorBindingExtension does not support binding to this path. There are only 3 properties 2 choose from; Converter, ConverterCulture and ConverterParameter, and neither seems to offer a binding path.

    So the values cannot be edited, and they need to be.

    Thanks for your help.

    Imported from legacy forums. Posted by Shelley (had 1072 views)

    Xceed Support
    Member
    Post count: 5658

    The CellEditorBinding binds directly to the cell’s actual content, that is why there is no path property. In your case, if you set the CellEditorBinding, it will attempt to bind to the “Left” value and not one of the “static” or “dynamic” values you are displaying.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 461 views)

    User (Old forums)
    Member
    Post count: 23064

    I updated my profile with a different email address, even though the one I had assigned wasn’t receiving any emails from the DataGrid team.

    I just contacted you by email, thanks

    Imported from legacy forums. Posted by Shelley (had 1066 views)

    Xceed Support
    Member
    Post count: 5658

    The request was for testn who was also replying in this thread 🙂

    I will make a quick sample to help you out with the CellEditorBinding issue.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 628 views)

    Xceed Support
    Member
    Post count: 5658

    If I am correct in assuming that you want to edit both the static and dynamic values of “Left”, then you can do the following (I have not tested this so you may need to tweak it):

    Create a control that has 2 textboxes; one for the static value and another for the dynamic value. The control should also have a DP to which you will be binding using the CellEditorBinding.

    Bind the text property of the first textbox to “Static.Amount” and the second to “Dynamic.Amount” retrieved from the DP.

    You should now be able to edit the values in both textboxes and have them update the cell content through the CellEditorBinding. HOWEVER, the values will be updated live and you will no longer be able to cancel the edit process.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 705 views)

    User (Old forums)
    Member
    Post count: 23064

    Yes, I want to edit both.

    Creating a control, is this done in XAML or C#? Could you point me in the direction of sample code? I’m not sure what you mean by DP, data provider?

    Imported from legacy forums. Posted by Shelley (had 663 views)

    Xceed Support
    Member
    Post count: 5658

    By DP I mean a dependency property to which you will be able to bind using a CellEditorBinding.

    Here is some quick pseudo code:

    <code>
    <EditTemplate>
    <DataTemplate>
    <local:MyControl.Left={CellEditorBinding}/>
    </DataTemplate>
    </EditTemplate>

    class MyControl : Control
    {

    //Control has 2 textboxes
    // TextBox1 Text={Binding Left.Static.Amount}
    // TextBox1 Text={Binding Left.Dynamic.Amount}

    public Left Left
    {
    get
    {
    return ( Left )GetValue( LeftProperty );
    }
    set
    {
    SetValue( LeftProperty, value );
    }
    }

    // Using a DependencyProperty as the backing store for Left. This enables animation, styling, binding, etc…
    public static readonly DependencyProperty LeftProperty =
    DependencyProperty.Register( “Left”, typeof( Left ), typeof( MyControl ), new UIPropertyMetadata( null ) );
    }
    </code>

    Imported from legacy forums. Posted by Jenny [Xceed] (had 818 views)

    User (Old forums)
    Member
    Post count: 23064

    in trying to convert pseudo code to code that will compile, I got this far.

    <xcdg:CellEditor x:Key=”LeftCellEditor”>
    <xcdg:CellEditor.EditTemplate>
    <DataTemplate>
    <local:MyControl.Left=”{xcdg:CellEditorBinding}/>
    </DataTemplate>
    </xcdg:CellEditor.EditTemplate>
    </xcdg:CellEditor>

    How should the CellEditorBinding line appear?

    Imported from legacy forums. Posted by Shelley (had 630 views)

    Xceed Support
    Member
    Post count: 5658

    <local:MyControl.Left=”{xcdg:CellEditorBinding}”/> is correct

    Imported from legacy forums. Posted by Jenny [Xceed] (had 404 views)

    User (Old forums)
    Member
    Post count: 23064

    I get this error from the compiler regarding that line…

    Error 1 ‘The ‘=’ character, hexadecimal value 0x3D, cannot be included in a name. Line 160, position 38.’ XML is not valid.

    Where are the textboxes created? You have them commented out in the C# MyControl class, I assume they are to be in the Data Template right?

    <xcdg:CellEditor x:Key=”LeftCellEditor”>
    <xcdg:CellEditor.EditTemplate>
    <DataTemplate>
    <StackPanel Orientation=”Vertical” >
    <TextBox Text=”???” />
    <Separator Style=”{DynamicResource SimpleSeparator}”/>
    <TextBox Text=”???” />
    </StackPanel>
    </DataTemplate>
    </xcdg:CellEditor.EditTemplate>
    </xcdg:CellEditor>

    I’m still missing the connection

    Imported from legacy forums. Posted by Shelley (had 1023 views)

    Xceed Support
    Member
    Post count: 5658

    “Where are the textboxes created? You have them commented out in the C# MyControl class, I assume they are to be in the Data Template right? “

    No. The TextBoxes should be in the control that you need to create. For example, you can derive from UserControl and add the textboxes and dependency property there. Then you use that user control as the data template and bind the dependency property you created in the user control using the CellEditorBinding.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 687 views)

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