【发布时间】:2017-06-07 05:30:42
【问题描述】:
我有一个注销的超链接,它应该隐藏在主页上,因为用户尚未登录。一旦用户登录,它应该是可见的。 我已将超链接中的文本替换为文本框,并在检查身份验证后设置其内容。
有没有一种方法,我们可以设置超链接的可见性,而不是使用 TextBox 作为其内容?
XAML 代码:
<TextBlock DockPanel.Dock="Right" TextAlignment="Center" Margin="0,0,0,10" Width="60">
<Hyperlink Name="lnkLogOut" Focusable="True" FontSize="16" FontStyle="Normal" Command="{Binding LogOutCommand}" Foreground="#AC0000">
<TextBlock Text="{Binding LogOutText}" />
<!--Log Out--> // this was the static text before
</Hyperlink>
</TextBlock>
型号:
private string _showlogOut = string.Empty;
public string ShowlogOut
{
get { return _showlogOut; }
set
{
SetProperty(ref _showlogOut, value);
}
}
视图模型:
if (_isLoginSuccessful)
{
ShowlogOut = "Log Out";
//.............other code...............
}
【问题讨论】:
标签: c# xaml mvvm hyperlink prism