J'ai un lien hypertexte pour Logout et il devrait être caché sur la page principale puisque l'utilisateur ne s'est pas encore identifié. Dès que l'utilisateur est dedans, il devrait être visible. J'ai remplacé le texte dans Hyperlink par une zone de texte et défini son contenu après avoir vérifié l'authentification.Lien hypertexte Visibilité dans MVVM et Prism
Existe-t-il un moyen, par lequel nous pouvons définir Visibilty of Hyperlink au lieu d'utiliser TextBox pour son contenu?
code 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>
Modèle:
private string _showlogOut = string.Empty;
public string ShowlogOut
{
get { return _showlogOut; }
set
{
SetProperty(ref _showlogOut, value);
}
}
ViewModel:
if (_isLoginSuccessful)
{
ShowlogOut = "Log Out";
//.............other code...............
}