Home Forums WPF controls Xceed DataGrid for WPF HotTo enable Two Way Databinding?

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

    On your documentation it says that two way binding is only enabled when the binding mode is set properly. How do i enable the TwoWay binding If i use ItemsSource from your grid? I am having a Singleton as Datasource:

    incidentView.ItemsSource = Model.GetInstance();

    The Model looks kind of like that (i would like to bind the grid to the items of the ObservableCollection):

    public class IncidentList : ObservableCollection<Incident>
    {

    private static Model _instance;
    public static Model GetInstance()
    {
    if (_instance != null) return _instance;
    else
    {
    _instance = new Model();
    return _instance;
    }
    }

    }

    Imported from legacy forums. Posted by Ralf (had 2826 views)

    User (Old forums)
    Member
    Post count: 23064

    I tryed it now with explicyt binding:

    Binding binding = new Binding(“GetInstance()”);
    binding.Mode = BindingMode.TwoWay;
    binding.Source = Model.GetInstance();
    incidentView.SetBinding(incidentView.Items, binding);

    If i understand things right i need a DependencyProperty from the Xceed datagrid. I tryed to use “Items” but ofcourse it does not work because it is am ItemCollection… Does the your datagrid provice something like a DependencyProperty or is there another way to achieve two way data binding?

    Thanks for the help in advance!

    Silas

    Imported from legacy forums. Posted by Ralf (had 334 views)

    User (Old forums)
    Member
    Post count: 23064

    it works, but only if i call grid.Items.Refresh(); not very practicable 🙁

    My Datasource object is an ObservableCollection of objects who implement the INotifyProperty interface. It should work, any idea why it doesn’t?

    cheers
    Silas

    Imported from legacy forums. Posted by Ralf (had 239 views)

    User (Old forums)
    Member
    Post count: 23064

    I have found out what my problem is:

    I was trying to use the datagrid in a project which we started earlier in .Net2.0. Obviously there is an interoperability problem between both technologies. Is there an easy way to get this working or should i rather stick to the “old fashioned” microsoft .Net20 control 🙂

    Imported from legacy forums. Posted by Ralf (had 3995 views)

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