First of all I'm using MVVM light toolkit for building my Windows Store app. So the datacontext will be set in ViewModelLocator. I'm trying to bind command for a button from Hub control's header. Here's my code from XAML which has button:
<DataTemplate x:Key="DataTemplate10">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="700"/>
<ColumnDefinition Width="800"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="user trading terminal"
Width="Auto"
Height="70"
Grid.Column="0"/>
<Button Content="sign in" Grid.Column="1"
Width="Auto"
HorizontalAlignment="Right" Command="{Binding SignIn}"/>
</Grid>
</DataTemplate>
Here's my Hub Control's XAML code from where I'm calling above datatemplate:
<Hub Header="user trading terminal" HeaderTemplate="{StaticResource DataTemplate10}">
<Hub.Background>
<ImageBrush Stretch="Fill" ImageSource="ms-appx:///Assets/HubImages/BackGround.jpg"/>
</Hub.Background>
<HubSection Header="indices" Width="500" ContentTemplate="{StaticResource DataTemplate1}" x:Name="indicesSection"/>
<HubSection Header="market movers" Width="530" ContentTemplate="{StaticResource DataTemplate4}"/>
<HubSection Header="commodities" Width="500" ContentTemplate="{StaticResource DataTemplate6}"/>
<HubSection Header="currency" Width="500" ContentTemplate="{StaticResource DataTemplate8}"/>
</Hub>
Following is my ViewModel's code:
public class ApplicationHubViewModel : ViewModelBase
{
private RelayCommand<object> _signIn;
/// <summary>
/// Gets the IndicesTap.
/// </summary>
public RelayCommand<object> SignIn
{
get
{
return _signIn
?? (_signIn = new RelayCommand<object>((t) => SignInProcess(t)));
}
}
private void SignInProcess(Object t)
{
IsPopUpOpen = true;
IsHubControlEnabled = false;
}
}
Can anyone tell me why I'm not able to call the button's command? Is it because I'm using MVVM light toolkit 5.2.0. Because normally in simple WPF application I'm able to call command without any problems.