Note that there are some explanatory texts on larger screens.

plurals
  1. POCommand Binding issues in AvalonDock
    primarykey
    data
    text
    <p>I have created an application where there's a series of command bindings attached to the MainWindow of my application:</p> <p>(Code simplified for brevity)</p> <pre><code>&lt;Window x:Class="DBBrowser.Design.Project.ProjectView" ...&gt; &lt;Window.CommandBindings&gt; &lt;Commands:DataContextCommandBinding Command="ProjectCommands:ProjectRoutedCommands.OpenReferenceList" Executed="OpenReferenceList" CanExecute="CanOpenReferenceList"/&gt; ... &lt;/Window.CommandBindings&gt; &lt;/Window&gt; </code></pre> <p>Within the project's ViewModel are two functions:</p> <pre><code>public bool CanOpenReferenceList(object parameter) { return true; } public void OpenReferenceList(object parameter) { var dockedReferenceList = new DockableUniversalListView() { Name = "referenceList", Title = "Reference List" }; referenceData = dockedReferenceList.DataContext as ReferenceListViewModel; if (referenceData != null) referenceData.EvListSelected += WoWObjectListRecieved; DockedWindows.Add(dockedReferenceList); } </code></pre> <p>Skipping over a bunch of details, there are 3 scenarios where this Command can be called:</p> <ol> <li>As a DockableContent within the application's main window</li> <li>As a new Window control, containing the DockableContent</li> <li>As a FloatingWindow, created by "tearing off" the window via AvalonDock</li> </ol> <p>Scenario #1 and #2 work perfectly using the following command binding:</p> <pre><code>&lt;Button Margin="2" Content="Validate" Height="23" Name="Validate" Width="75" Command="ProjectCommands:ProjectRoutedCommands.OpenReferenceList" CommandTarget="{Binding Path=MainWindow.DataContext,Source={x:Static Application.Current}}" DockPanel.Dock="Left" CommandParameter="{Binding Path=SelectedWoWObjectList}" TabIndex="20" HorizontalAlignment="Right"/&gt; </code></pre> <p>However, when I "Tear off" the AvalonDock window, the button greys out. However, a stack trace showed that CanExecute() was being called AND returning true for that button... but the Button remained disabled. </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