Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So there seems to be two problems here..</p> <p>I would probably be tempted to set a property after calling IncludesCanExecuteCommand.RaiseCanExecuteChanged() which will cause the command to reevaluate its CanExecuteCommand..</p> <p>Put the hyperlink in a panel and then bind the visibility to the property in 1.) with a converter to return a valid Visiblility enum such as Collapsed, Visible etc.</p> <p>So for clarity - something like</p> <pre><code>&lt;StackPanel Visibility="{Binding IsHyperlinkVisible, Mode=TwoWay, Converter=boolToVisibilityConverter}"&gt; &lt;TextBlock&gt; &lt;Hyperlink Command="{Binding WhateverTheHyperlinkDoesCommand}"&gt;Link text&lt;/Hyperlink&gt; &lt;/TextBlock&gt; &lt;/StackPanel&gt; </code></pre> <p>And the viewmodel looks something like this (if the viewmodelbase implements some version of NotifyPropertyChanged...</p> <pre><code> public class ViewModel : NotificationViewModelBase { public ViewModel() { this.WhateverTheHyperlinkDoesCommand = new DelegateCommand&lt;object&gt;( this.ExecuteWhateverTheHyperlinkDoesCommand, this.CanWhateverTheHyperlinkDoesCommand); } private void ExecuteWhateverTheHyperlinkDoesCommand(object arg) { this.SomeOtherProperty = true; } private bool someOtherProperty; public bool SomeOtherProperty { get { return this.someOtherProperty; } set { if (this.ChangeAndRaisePropertyChanged( () =&gt; this.SomeOtherProperty, value, ref this.someOtherProperty)) { this.WhateverTheHyperlinkDoesCommand.RaiseCanExecuteChanged(); } } } private bool isHyperlinkProperty; public bool IsHyperlinkProperty { get { return this.isHyperlinkProperty; } set { this.ChangeAndRaisePropertyChanged(() =&gt; this.IsHyperlinkProperty, value, ref this.isHyperlinkProperty); } } private bool CanWhateverTheHyperlinkDoesCommand(object obj) { // So based on a certain condition - lets say some other property if (this.SomeOtherProperty == false) { this.IsHyperlinkProperty = true; return false; } this.IsHyperlinkProperty = false; return true; } public DelegateCommand&lt;object&gt; WhateverTheHyperlinkDoesCommand { get; set; } </code></pre> <p>} }</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload