Note that there are some explanatory texts on larger screens.

plurals
  1. POHyperlink doesn't work properly with associated command
    primarykey
    data
    text
    <p>I have <code>Hyperlink</code> in a <code>Grid</code>. I bind command to hyperlink that Enables/Disables it. Then I disable it using the command. Then on its parent (<code>Grid</code>) I set <code>IsEnabled=False</code> property. After that I enable my Hyperlink with my command and enable Grid, but hyperlink doesn't activate!</p> <p>Here is sample:</p> <pre><code>Command testCommand = new Command(); public MainWindow() { InitializeComponent(); hl.Command = testCommand; } private void Start(object sender, RoutedEventArgs e) { //Disable Hyperlink testCommand.Enabled = false; //Disable Grid grid.IsEnabled = false; //Enable Hyperlink testCommand.Enabled = true; //Enable Grid grid.IsEnabled = true; //hl.IsEnabled = true; //if uncomment this all will be work } </code></pre> <p>XAML:</p> <pre><code>&lt;Window x:Class="WpfApplication25.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="172" Width="165"&gt; &lt;StackPanel&gt; &lt;Grid x:Name="grid"&gt; &lt;TextBlock&gt; &lt;Hyperlink x:Name="hl"&gt;Test&lt;/Hyperlink&gt; &lt;/TextBlock&gt; &lt;/Grid&gt; &lt;Button Content="Start" Name="button1" Click="Start" /&gt; &lt;/StackPanel&gt; &lt;/Window&gt; </code></pre> <p>And register an ICommand:</p> <pre><code>public class Command : ICommand { private bool enabled; public bool Enabled { get { return enabled; } set { enabled = value; if (CanExecuteChanged != null) CanExecuteChanged(this, EventArgs.Empty); } } public bool CanExecute(object parameter) { return Enabled; } public event EventHandler CanExecuteChanged; public void Execute(object parameter) { } } </code></pre> <p><strong>Update:</strong></p> <p>If Hyperlink is replaced with Button, it will be enabled even if its parent is disabled (grid.IsEnabled = false).</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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