|
|
Question : Command:Click:Command is working fine for Button but its not working for Hyperlink
|
|
|
|
Commands:Click.Command is working fine for button but its not working when I do the same thing for hyperlink.My goal is when the user click on button or hyperlink I need to close the menu popup Its work fine for button but its not actually invoking the click command for hyperlink.We are using MVVM pattern for doing this. //Button <Button Grid.Row="0" Style="{StaticResource MenuItemButton}" Padding="4,3,3,3" Commands:Click.Command="{Binding ListLayoutCommand}" Commands:Click.CommandParameter="Vertical">
//Hyperlink <HyperlinkButton Style="{StaticResource MenuItemLinkButton}" Padding="32,3,3,3" Commands:Click.CommandParameter="null" Commands:Click.Command="{Binding CloseMenuCommand}" ToolTipService.ToolTip="{Binding Description}" Content="{Binding Name}" NavigateUri="{Binding Value}" TargetName="_blank"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Canvas Height="16" Width="16" Grid.Column="0"> <!-- TODO: replaces this canvas placeholder with an appropriate icon --> </Canvas> <TextBlock Grid.Column="1" VerticalAlignment="Center" Text="{Binding Name}" Margin="10,0,0,0"/> </Grid> </HyperlinkButton>
//This code is working fine its actaully gets invoked when the user click on the button public ICommand TileLayoutCommand { get; private set; } //This is were we are appending with DelegateCommand in the constructor this.TileLayoutCommand = new DelegateCommand<string>( this.OnLayoutClick );
//When the user clicks on button we are invoking
private void OnLayoutClick( string parameter ) { var orientation = (Orientation) System.Enum.Parse( typeof( Orientation ), parameter, false ); this.layoutManager.ApplyLayout( orientation ); MenuService.CloseMenu(); }
But I have done the same think for hyperlink which is not working.
/// <value>An <see cref="ICommand"/> object.</value> public ICommand CloseMenuCommand { get; private set; }
This is the property which is not getting triggered when the user clicks on the hyperlink.
this.CloseMenuCommand = new DelegateCommand<object>( p => Microsoft.Advertising.Controls.MenuService.CloseMenu() );
Do I need to do some thing for invoking this method for the hyperlink.Could any one please help me out with this issue.
|
|
|
|
Answer : Command:Click:Command is working fine for Button but its not working for Hyperlink
|
|
</HyperlinkButton> , end tag is in wrong place. Try placing it top of <Grid> tag
|
|
|
|