So I've got a hyperlink that I have hooked up to the code behind like so:
Xaml
<TextBlock x:Name="Hyperlink" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="3" FontSize="14" Foreground="White">
<Hyperlink NavigateUri="{Binding StreetViewString}" RequestNavigate="Hyperlink_RequestNavigate" Foreground="White" StylusDown="Hyperlink_StylusDown" TouchDown="Hyperlink_TouchDown">
Google
</Hyperlink>
</TextBlock>
Code Behind
private void addToDiary_MouseDown(object sender, MouseButtonEventArgs e)
{
((sender as Button).DataContext as MyViewModel).MyCommand.Execute(null);
e.Handled = true;
}
But I would like to hook this straight up to the command it is executing
private ICommand _myCommand;
public ICommand MyCommand
{
get
{
return _myCommand
?? (_myCommand= CommandFactory.CreateCommand(
() =>
{
DoSomething();
}));
}
}
but the only thing that is stopping me is that I cannot set e.Handled = true
from my command. Is it possible to do this without using the code behind?
Aucun commentaire:
Enregistrer un commentaire