Home Forums WPF controls Xceed DataGrid for WPF TwoWay DataBinding With ObservableCollection

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

    In my Project i need a Two Way Binding to the following Class. Since i need access to the same dataset from different Elements of my user interface i was planning to do a Singleton Pattern. (“Items” is a simple class with some properties and implements the interface “INotifyPropertyChanged”)
    For some reasons two way binding does not work. When i tried to do the binding in XAML i got a runtime error. Doing it in C# got me only to a OneWay binding. To make it short… Changes in the View do not affect my Dataset.

    public class Model : ObservableCollection<Items>
    {

    private static Model _instance;

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

    Any suggestions?

    Thanks in advance!

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

    User (Old forums)
    Member
    Post count: 23064

    I found out that the datasource will be updated when i hit the “return” button to confirm the value. Is there a way that the datasource will be updated when i leave a cell automatically even without hitting the return button?

    Cheers

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

    User (Old forums)
    Member
    Post count: 23064

    For anybody who is reading this thread, here is the solution i found so far (Some Eventhandling…):

    OrdersGrid.KeyUp += new KeyEventHandler(OrdersGrid_KeyUp);

    private void OrdersGrid_KeyUp(object sender, KeyEventArgs args)
    {
    if (args.Key == Key.Tab)
    {
    Xceed.Wpf.DataGrid.DataRow dr = OrdersGrid.ItemContainerGenerator.ContainerFromItem(OrdersGrid.CurrentItem) as Xceed.Wpf.DataGrid.DataRow;
    if (dr != null)
    dr.EndEdit();
    }
    }

    Take care
    Silas

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

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