Hi I am trying to add AppBarButton in a ListView and binded command to RelayCommand in ViewModel here is my xaml code
<DataTemplate x:Key="MyTemplage" >
<Grid HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<AppBarButton Grid.Column="1" Command="{Binding DoCommand,Mode=OneWay}">
<AppBarButton.Icon>
<BitmapIcon UriSource="ms-appx:///assets/doIcon.png"></BitmapIcon>
</AppBarButton.Icon>
</AppBarButton>
</DataTemplate>
<ListView HorizontalAlignment="Left" Margin="0,45,0,0" Background="Khaki" VerticalAlignment="Top" ItemsSource="{Binding AList, Mode=TwoWay}"
ItemTemplate="{StaticResource MyTemplage}">
</ListView>
here is my Relay command code in VM
private RelayCommand _DoCommand;
/// <summary>
/// Gets.
/// </summary>
public RelayCommand DoCommand
{
get
{
return _DoCommand
?? (_DoCommand = new RelayCommand(
() =>
{
DoSomething();
}));
}
}
DoCommand is not raising in ViewModel. If I register click event handler in code behind it works fine. also AppBarButton is wokring fine with MVVM if I use it in Page.Bottombar.
any ideas?