Home Forums WPF controls Xceed DataGrid for WPF Combo Box Cell Editor bug

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • Xceed Support
    Member
    Post count: 5658
    #22261 |

    Hi all,

    I’m using your Grid with every column created in code-behind, with an insertionRow, in one of the column I have a Combo Box CellEditor: you can see http://forums.xceed.com/forums/ShowPost.aspx?PostID=5611

    I have a few item in the grid, and the problem occurs when I want to update the value in one of the cell of the column that has the Combo Box CellEditor, after the value has been updated the following error appears:

    System.InvalidOperationException = Dispatcher processing has been suspended, but messages are still being processed.
    Message = Dispatcher processing has been suspended, but messages are still being processed.
    Exception’s Data
    Message = Dispatcher processing has been suspended, but messages are still being processed.
    (Dictionary with 1 entrie(s))
    TargetSite = IntPtr WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
    Source = WindowsBase
    Stack Trace = at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
    at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)

    Imported from legacy forums. Posted by Simon (had 3067 views)

    Xceed Support
    Member
    Post count: 5658

    Can you provide more context on the circumstances of the problem:

    – Are you updating programatically or through the UI?
    – If programatically, are you changing the Data Object’s value of the Cell’s content?
    – If through the UI can you provide the up to date code for the Editor?
    – What is the value being set in the editor/cell?

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

    Xceed Support
    Member
    Post count: 5658

    -I’m updateing through the UI with Databinding

    private ColumnEx CreateDropDownListTemplate( ColumnEx aColumn, string aPropertyToBind, ListColumnValueListAttribute aListColumnValueListAttribute )
    {
    CellEditor cellEditor = new CellEditor();
    FrameworkElementFactory comboBox = new FrameworkElementFactory( typeof( ComboBoxEx ) );

    //init the combo box
    comboBox.SetValue( ComboBoxEx.NameProperty, “comboBoxExTemplate” );
    comboBox.SetValue( ComboBoxEx.BackgroundProperty, Brushes.Transparent );
    comboBox.SetValue( ComboBoxEx.BorderThicknessProperty, new Thickness( 0, 0, 0, 0 ) );
    comboBox.SetValue( ComboBoxEx.DisplayMemberPathProperty, aListColumnValueListAttribute.DisplayMember );
    comboBox.SetValue( ComboBoxEx.SelectedValueProperty, new Binding( aPropertyToBind ) );

    //CellContentTemplate
    FrameworkElementFactory textBlockEx = new FrameworkElementFactory( typeof( TextBlock ) );
    textBlockEx.SetValue( TextBlock.TextProperty, new Binding( aListColumnValueListAttribute.DisplayMember ) );
    DataTemplate dataTemplate = new DataTemplate();
    dataTemplate.VisualTree = textBlockEx;

    //CellEditorBinding
    CellEditorBindingExtension cellEditorBinding = new CellEditorBindingExtension();
    comboBox.SetBinding( ComboBoxEx.SelectedValueProperty, cellEditorBinding.ProvideValue( null ) as BindingBase );

    //Fill the combo box
    IEntityManager entityManager = ServiceManager.Instance.Get<IEntityManager>();
    List<IEntity> entityList = entityManager.GetAll( aListColumnValueListAttribute.Type );
    comboBox.SetValue( ComboBoxEx.IsSortedProperty, true );
    comboBox.SetValue( ComboBoxEx.ItemsSourceProperty, entityList );
    comboBox.AddHandler( ComboBoxEx.SelectionChangedEvent, new SelectionChangedEventHandler( Template_SelectionChanged ) );

    cellEditor.EditTemplate = new DataTemplate();
    cellEditor.EditTemplate.VisualTree = comboBox;

    aColumn.CellEditor = cellEditor;
    aColumn.CellContentTemplate = dataTemplate;
    aColumn.CellValidationRules.Add( new SelectedValueValidationRule() );

    return aColumn;
    }

    -I’m binding this property to the combo box SelectedValue
    public PhoneNumberType PhoneNumberType
    {
    get
    {
    return this.PhoneNumberType;
    }
    set
    {
    this.PhoneNumberType = value;
    }
    }

    Imported from legacy forums. Posted by Simon (had 4231 views)

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