This is a migrated thread and some comments may be shown as answers.

Problem with DataContext.

1 Answer 98 Views
Window
This is a migrated thread and some comments may be shown as answers.
Sergiy
Top achievements
Rank 1
Sergiy asked on 14 Sep 2012, 10:09 AM
Hi, I try binding command, but it doesn't work.

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

xaml:

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

But it works when I indicates the specific component:

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

1 Answer, 1 is accepted

Sort by
0
Vladi
Telerik team
answered on 19 Sep 2012, 07:50 AM
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.

Regards,
Vladi
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.

Tags
Window
Asked by
Sergiy
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Share this question
or