Home Forums WPF controls Xceed DataGrid for WPF How to refresh cells that uses a Combobox cell editor?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #25621 |

    In short my problem is to get the current selected item in a combobox editcell refreshed when the collection bound to the combobox is changed.

    This is what I’m doing:

    First I have a simple “data container” class:
    public class AccountDef
    public AccountDef(string s, int Id) { Text = s; ID = Id; }

    public string Text { get; set; }
    public int ID { get; set; }

    public override string ToString()
    return Text;

    Then I make an observable collation from this:

    private ObservableCollection<AccountDef> m_AccountDefs =
    new ObservableCollection<AccountDef>();

    Then I have another “data container” class that useses the first one:

    public class Post
    public Post(string text, AccountDef account) { Text = text; Account = account; }

    public string Text {get; set;}
    public AccountDef Account { get; set; }

    public override string ToString()
    return Text;

    Which I also use in an observable collection:

    private ObservableCollection<Post> m_Items = new ObservableCollection<Post>();

    this I bind to a DataGridControl in XAML:
    <xcdg:DataGridCollectionViewSource x:Key=”griditems”
    Source=”{Binding Source={x:Static Application.Current}, Path=Items}”/>

    <xcdg:DataGridControl x:Name=”PostGrid”
    ItemsSource=”{Binding Source={StaticResource griditems}}”>

    and finally I define a Combobox cell editor for the Account column in XAML:

    <ObjectDataProvider x:Key=”accounts”
    ObjectType=”{x:Type c:Account}”>
    <x:Type TypeName=”c:Account”/>

    <xcdg:CellEditor x:Key=”accountEditor”>
    <ComboBox BorderThickness=”0″
    Foreground=”{Binding RelativeSource={RelativeSource TemplatedParent},
    ItemsSource=”{Binding Source={x:Static Application.Current},
    ItemTemplate=”{StaticResource accountDataTemplate}”
    <Style TargetType=”Popup”>
    <Setter Property=”TextElement.Foreground”
    Value=”{DynamicResource {x:Static
    SystemColors.WindowTextBrushKey}}” />
    <xcdg:KeyActivationGesture SystemKey=”Down”
    <xcdg:KeyActivationGesture Key=”Up”
    <xcdg:KeyActivationGesture Key=”F4″/>
    <xcdg:KeyActivationGesture Key=”Space”/>

    I attach this to the DataGridControl in the “Code behind”:
    PostGrid.Columns[“Account”].CellEditor =
    this.FindResource(“accountEditor”) as CellEditor;

    This all works fine until I change the Text in one of the AccountDefs (This text is the one shown in the Account column DataGridControl)
    If I open an account combobox (my custom made Cell editor) after the Text has been changed, the modified text shows up fine.
    My question is: How do I refresh the DataGridCotrol so that the column using my custom made Cell Editor reflects the values bound to it?
    (Refresh() doesn’t help!)


    Imported from legacy forums. Posted by Claus (had 2193 views)

    User (Old forums)
    Post count: 23064

    I have the same problem. How do you refresh the cell?

    Imported from legacy forums. Posted by Wally (had 3169 views)

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