DataGrid 'EditItem' is not allowed for this view when dragging multiple items

前端 未结 6 1397
一向
一向 2021-01-05 08:53

I have a datagrid which gets data like this:

    public struct MyData
    {
        public string name { set; get; }
        public string artist { set; ge         


        
6条回答
  •  长发绾君心
    2021-01-05 09:48

    For my case,

    processLimits.OrderBy(c => c.Parameter);
    

    returns an

    IOrderedEnumerable 
    

    not a

    List
    

    so when I assign a style for my event setter to a checkbox column in my datagrid

    style.Setters.Add(new EventSetter(System.Windows.Controls.Primitives.ToggleButton.CheckedEvent, new RoutedEventHandler(ServiceActiveChecked)));
    

    ServiceActiveChecked is never called and I got

    'EditItem' is not allowed for this view.
    

    and for anyone else doing checkboxes in datagrid columns, I use a column object with my column data in this constructor for adding the data grid I use with adding the style above.

    datagridName.Columns.Add(new DataGridCheckBoxColumn()
                                {
                                    Header = column.HeaderText.Trim(),
                                    Binding = new System.Windows.Data.Binding(column.BindingDataName.Trim()) { StringFormat = column.StringFormat != null ? column.StringFormat.Trim().ToString() : "" },
                                    IsReadOnly = column.IsReadOnlyColumn,
                                    Width = new DataGridLength(column.DataGridWidth, DataGridLengthUnitType.Star),
                                    CellStyle = style,
                                });
    

提交回复
热议问题