Note that there are some explanatory texts on larger screens.

plurals
  1. POBind a Command to a Button inside a ListView with Caliburn.Micro
    primarykey
    data
    text
    <p>I'm trying to create something like a MDI tabbed Interface so I have a navigation pane (a Listbox) on the left, and a ContentPresenter on the right.</p> <p>I have a ShellViewModel that has a BindableCollection on it called AvailAbleScreens and I managed successfully to bind to that list with a ListViews DataTemplate:</p> <pre><code>&lt;ListView x:Name="AvailableScreens"&gt; &lt;ListView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;WrapPanel&gt; &lt;BulletDecorator /&gt; &lt;Button x:Name="DisplayView"&gt; &lt;TextBlock Text="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}" /&gt; &lt;/Button&gt; &lt;/WrapPanel&gt; &lt;/DataTemplate&gt; &lt;/ListView.ItemTemplate&gt; </code></pre> <p>The problem now is that although the Name of the Button is set correctly, I can't make the Command fire for me. On the MdiViewModel class I have the following code for that button:</p> <pre><code>public bool CanDisplayView() { return true; } public void DisplayView() { MessageBox.Show("Hello"); } </code></pre> <p>All the Caliburn.Micro samples work with binding through conventions to the x:Name Property, but if I remove the Text="{Binding}" it stops working so I suspect that this way of databinding doesn't work for sub-models? </p> <p>Anyway, the Shell's ViewModel is quite simple at the moment:</p> <pre><code>ShellViewModel * AvailableScreens -MdiViewModel1 -MdiViewModel2 * CurrentActiveScreen </code></pre> <p>Any Idea how I'd do this with Caliburn.Micro? Rob Eisenberg suggested to me on Twitter I might want to start out with Caliburn.Micro before going into the full fledged Caliburn framework.</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