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
Show floating point decimal place even for whole numbers in php
How can I present multiple percentages in MSSQL server derived from a single cell then over multiple rows?
windows 2003 repair end up in dos mode
Quick Excel Question
Can't Create New Calendar Entries
export report to excel with bitmap (picture)
Mysterious SMTP Sessions
CSS
How to raise Hyperlinkfield event in a gridview using asp.net 3.5
Unable to create the website error