Reputation: 45
I am trying to bind a command to a view model but it is not triggering
xmlns:ViewModel="clr-namespace:Lister.WPF.ViewModels"
DataContext="{Binding ViewModel:TweetViewModel}" Icon="pack://siteoforigin:,,,/Resources/internet_down_16_hot.png" Loaded="Window_Loaded">
<Grid>
<!--Test-->
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem BorderThickness="5" Header="Status">
<MenuItem BorderThickness="5" Header="Timeline" Command="{Binding RefreshTweetsCommand}"/>
Here is the code from the VM
private RelayCommand _refreshTweetsCommand;
public RelayCommand RefreshTweetsCommand
{
get
{
return _refreshTweetsCommand ??
(_refreshTweetsCommand =
new RelayCommand(RefreshTweetList, LoadTweets));
}
}
Upvotes: 0
Views: 81
Reputation: 18580
DataContext="{Binding ViewModel:TweetViewModel}"
This is no way of binding DataContext
.
Set your DataContext as follows:
<Window>
<Window.DataContext>
<ViewModel:TweetViewModel/>
</Window.DataContext>
</Window>
Upvotes: 2