Microsoft
Software
Hardware
Network
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="{B
inding ListLayoutCommand}"
Commands:Click.CommandPara
meter="Ver
tical">
//Hyperlink
<HyperlinkButton Style="{StaticResource MenuItemLinkButton}"
Padding="32,3,3,3"
Commands:Click.CommandPara
meter="nul
l"
Commands:Click.Command="{B
inding CloseMenuCommand}"
ToolTipService.ToolTip="{B
inding 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.ApplyLa
yout( 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.Cont
rols.MenuS
ervice.Clo
seMenu() );
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
Random Solutions
Implementing Windows Deployment Services
Schedule .vbs & .bat files - HELP NEEDED!
Contact form on website requires authentication
Trasnpose rows and columns in SQL
Calling Events and Event Handlers in Java
How to remove User Name and Password from Login screen
Multiple <html> Tags in Page?
Where do I get MS OEM media for Windows 7 upgrade?
Dell PE T300 Win 2008 server stuck in loop
Exchange 2003 to Exchange 2010 Migration - Stuck at SSL & URL