Problem with DataContext.

2 posts, 0 answers
  1. Sergiy
    Sergiy avatar
    38 posts
    Member since:
    Jan 2012

    Posted 14 Sep 2012 Link to this post

    Hi, I try binding command, but it doesn't work.

    private readonly EmployeeContextViewModel _ucvm;
    public MainWindow() // RadWindow
         _ucvm = new EmployeeContextViewModel();
         DataContext = _ucvm;  // <<<<<<<<<


    <t:RadButton Content="Exit"
          Command="{Binding LogoutCommand}"/>

    But it works when I indicates the specific component:

    public MainWindow()
         _ucvm = new EmployeeContextViewModel();
        LoginButton.DataContext = _ucvm; // <<<<<<<<<<<<<< 
    everything works fine.
    Why doesnot work in the first case and how to fix it?

  2. Vladi
    Vladi avatar
    743 posts

    Posted 19 Sep 2012 Link to this post

    Hello Sergiy,

    The command bindings seem to be correct but there may be something causing the issue in the ViewModel.

    Can you send us a runnable project that recreates the issue in order for us to be able to assist you accordingly.

    Looking forward to your response.

    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  3. DevCraft R3 2016 release webinar banner
Back to Top