Button not enabling

Sep 24, 2010 at 6:23 PM

Hi All,

First thanks for you time looking this over with me.

I have a functioning Silverlight app I created use CM. The App is working fine overall and I was starting to expand it functionality and was trying to add a button to my shell that would open up a view with Stylize Icons that a selection would be made from. (Link to current if any are interested: http://www.theflighthangar.com/fsx/utls/fseactivemap/fseactivemaptestpage.html)

The problem:
Just adding a standard button entry to my ShellView.xaml, naming it DisplayMenu, and then adding in the associated DisplayMenu method in the VM with a CanDisplayMenu method to ShellViewModel.cs, the button is never enabled.

What I know:
The CanDisplayMenu is being called, returning true (or I can just comment it out with the same results.)
In following with the debugger its setting the isEnable to true, however the button remains in the disabled state.
I can create a button in my composite view that is loaded, and it works.

Solutions?
I am scratching my head on this one, the only thing I can think is happening is that there is something 'special' with Conductor over Screen that I am missing.
Is this another newb mistake? Something obvious I am overlooking?

Here is the code.

So I added a button named DisplayMenu to ShellView.xaml in my Title area as follows:

<UserControl x:Class="FSEActiveMapCM.Views.ShellView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:tc="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:tl="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
    xmlns:Resources="clr-namespace:FSEActiveMapCM.Resources"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400"
    MinHeight="600" MinWidth="800">

    <Border Margin="0" Background="#000033" BorderThickness="2" BorderBrush="Gold">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>

            <Border Margin="3" BorderThickness="2" BorderBrush="Goldenrod" CornerRadius="8">
                <StackPanel>
                    <tc:DockPanel>
                        <TextBlock x:Name="Title" tc:DockPanel.Dock="Left" Margin="2" FontFamily="Arial" FontSize="24" FontWeight="Bold" Foreground="Gold" TextAlignment="Left">
                        <TextBlock.Effect>
                            <DropShadowEffect ShadowDepth="1" Color="Gray" BlurRadius="10"></DropShadowEffect>
                        </TextBlock.Effect>
                        <TextBlock.Text>FSE Active Map</TextBlock.Text>
                        </TextBlock>
                        <Button x:Name="DisplayMenu" tc:DockPanel.Dock="Right" Margin="0,0,10,0" HorizontalAlignment="Right">Menu</Button>
                    </tc:DockPanel>
                </StackPanel>
            </Border>

            <Resources:Background />
                
            <tl:TransitioningContentControl x:Name="Shell" Grid.Row="1"  Transition="UpTransition" Margin="2"/>

        </Grid>
    </Border>

</UserControl>
----------------------------------
Simple enough, So now here is the code that is in my ShellViewModel.cs:

using System.ComponentModel.Composition;
using System.Windows;
using Caliburn.Micro;
using FSEActiveMapCM.Framework;

namespace FSEActiveMapCM.ViewModels
{
    [Export(typeof(IShell))]
    public class ShellViewModel : Conductor<IScreen>, IShell
    {
        [ImportingConstructor]
        public ShellViewModel(FlightInfoViewModel fivm)
        {
            Shell = fivm;
        }

        private object _shell;
        public object Shell
        {
            get { return _shell; }
            set
            {
                _shell = value;
                NotifyOfPropertyChange(() => Shell);
            }
        }

        public void DisplayMenu()
        {
            MessageBox.Show("Display Menu"); //Testing
        }

        public bool CanDisplayMenu()
        {
            return true;
        }
    }
}
Coordinator
Sep 24, 2010 at 6:38 PM

Well, nothing is sticking out for me.  Can you email me a small solution that reproduces the problem? Please send it to robertheisenberg at hotmail dot com

Sep 25, 2010 at 2:33 AM

Stripped down version has been sent.

Sep 26, 2010 at 7:49 PM
Edited Sep 26, 2010 at 8:26 PM

I have determined the problem element. 

<Resources:Background />

What exactly I am unsure of at the moment, but if I comment that line out, Grid.Row="0" is no longer disabled.

 

Edit:

Turns out it was a newb error after all, the issue was that the background resource needed to be the first item declared in the grid. As I was adding elements it was pushed down to the middle and ended up and now instead of be overlayed, it was doing the overlaying causing weird behavior with the first grid row.

 

Sorry for that.