Can't find explanation of Members

Jul 7, 2011 at 2:38 PM

Hi,

This is a wonderful tool, and I look forward to getting it running.

I'm having touble getting it to behave as I thought it might.  In order to tweak the properties, I looked for some explanation of them but can't find any.

Can someone point me in the right direction to find out what each property does?

Thanks so much,

JJW

Coordinator
Jul 7, 2011 at 5:25 PM

Hi Jack,

Until I release the documentation help file which will be included in the next release you can access a brief explanation for most properties by hovering them or selecting them right inside your intellisense.

I haven't yet documented all of them however. This is often the case for methods or functions having several overloads in which case only the overload having the most parameters is documented.

I've included quite a few usage examples in the demo but if you're trying to achieve something different you can always ask me.

Regards

Ziad

Jul 7, 2011 at 5:57 PM

Ziad,

You are the best.

I’ve made a tiny bit of progress since I posted my query, but I’m still in a confused state.

I will post what I’m working with, both Xaml and .cs as well as what I want to end up with.

Perhaps you can advise which properties to set to what in order for me to achieve the end goal.

Thanks Again,

Jack Webb

(904) 554-6392

From: ZiadJ [email removed]
Sent: Thursday, July 07, 2011 1:26 PM
To: jackwebb22002@hotmail.com
Subject: Re: Can't find explanation of Members [SL4PopupMenu:264262]

From: ZiadJ

Hi Jack,

Until I release the documentation help file which will be included in the next release you can access a brief explanation for most properties by hovering them or selecting them right inside your intellisense.

I haven't yet documented all of them however. This is often the case for methods or functions having several overloads in which case only the overload having the most parameters is documented.

I've included quite a few usage examples in the demo but if you're trying to achieve something different you can always ask me.

Regards

Ziad

Jul 7, 2011 at 6:23 PM

Here is what I'm trying to do:

The end objective is to have a plainly visible Menu with three sub menus that look like this:
 Data
  Job Report
  Update Hourly Wage Rates
  Edit a Job
 Projection
  Enter Job PP Usage
  Job Projections
 Users
  Manage Users
  User Roles
  New User

To that End Here is my .xaml, follwed by my .xaml.cs:
<navigation:Page
  x:Class="AgmaSL5.Administrator"
    xmlns:my2="clr-namespace:AgmaSL5.Controls" 
    Title="Administrator Page"
    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"
    mc:Ignorable="d"
    xmlns:dds="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    d:DesignWidth="1040" d:DesignHeight="480"
    xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
    xmlns:gs="sy"
    xmlns:my="clr-namespace:AgmaSL5.Web.Models"
    xmlns:csys="clr-namespace:System;assembly=mscorlib"
    xmlns:my1="clr-namespace:AgmaSL5.Web.Services"
    xmlns:web="clr-namespace:AgmaSL5.Web.Services"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:myMenu="clr-namespace:SL4PopupMenu;assembly=SL4PopupMenu"
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" xmlns:my3="clr-namespace:SL4PopupMenu;assembly=SL4PopupMenu">
    <navigation:Page.Resources>
        <web:AgmaContext x:Key="AgmaContext"/>
        <!--<riaControls:DomainDataSource AutoLoad="False" d:DesignData="{d:DesignInstance my:QJob, CreateList=true}"
          Height="0" LoadedData="dds_qJobCurrent_LoadedData" x:Name="dds_qJobCurrent"
          QueryName="GetQJobsByContractorQuery" Width="0" DomainContext="{StaticResource AgmaContext}" DataContext="{Binding}" />-->
        <!--<riaControls:DomainDataSource AutoLoad="False" d:DesignData="{d:DesignInstance my:QJob, CreateList=true}"
          Height="0" LoadedData="dds_qJobNew_LoadedData" x:Name="dds_qJobNew"
          QueryName="GetQJobsByContractorNewQuery" Width="0" DomainContext="{StaticResource AgmaContext}"/>
        <riaControls:DomainDataSource AutoLoad="False" d:DesignData="{d:DesignInstance my:QJob, CreateList=true}"
          Height="0" LoadedData="dds_qJobOther_LoadedData" x:Name="dds_qJobOther"
          QueryName="GetQJobsByContractorOtherQuery" Width="0" DomainContext="{StaticResource AgmaContext}" DataContext="{Binding}"/>-->
    </navigation:Page.Resources>

    <Grid x:Name="LayoutRoot">
     <Grid.RowDefinitions>
      <RowDefinition Height="0.15*"/>
      <RowDefinition Height="0.85*"/>
     </Grid.RowDefinitions>
     <Grid.ColumnDefinitions>
      <ColumnDefinition Width="0.25*"/>
      <ColumnDefinition Width="0.75*"/>
     </Grid.ColumnDefinitions>
      <StackPanel x:Name="ContentStackPanel" Style="{StaticResource ContentStackPanelStyle}">
        <TextBlock Name="HeaderText" Style="{StaticResource HeaderTextStyle}" Text="{Binding Path=Strings.AdministratorPageTitle, Source={StaticResource ApplicationResources}}" />
      </StackPanel>
    <StackPanel Grid.Row="0" Grid.Column="1" Margin="3" Visibility="Visible">
          <ListBox Grid.Row="0" Grid.Column="1" Margin="10" Style="{StaticResource TopMenuStyle1}"
            ItemContainerStyle="{StaticResource TopMenuItemContainerStyle1}"       
            ItemsPanel="{StaticResource TopMenuItemPanelStyle1}" HorizontalAlignment="Left">
          <ListBoxItem x:Name="TopHoverMenu2" Content="Click this to view Administrator's Menu" HorizontalAlignment="Left" />
        </ListBox>
      </StackPanel>
    <StackPanel Grid.Row="1" Grid.Column="1">
      <Button Name="MenuItem" Click="MenuItem_Click" Content="Selection" HorizontalAlignment="Left" Margin="90,4,0,0" Padding="6" />
      <myMenu:PopupMenu x:Name="PopupMenu" HoverElements="MenuItem" LeftClickElements="MenuItem" Style="{StaticResource PopupMenuWithBorderMaskStyle1}" Margin="4" Height="276" Orientation="Bottom" BorderBrush="RoyalBlue" BorderThickness="8" OpenOnAccessKeyPressed="True" AccessShortcut="Ctrl+Alt+M" RightClickElements="MenuItem">
        <ListBox x:Name="lsToptMenu2" Style="{StaticResource MenuStyle1}" ItemContainerStyle="{StaticResource MenuItemContainerStyle1}" Margin="4" Padding="1">
          <myMenu:PopupMenuItem Header="Data" ImageRightSource="../images/arrow.png">
            <myMenu:PopupMenu>
              <ListBox Style="{StaticResource MenuStyle1}" ItemContainerStyle="{StaticResource MenuItemContainerStyle1}">
                <myMenu:PopupMenuItem x:Name="JobReport" Header="Job Report" Click="MenuItem_Click"/>
                <myMenu:PopupMenuItem x:Name="UpdateHourlyWageRates" Header="Update Hourly Wage Rates" Click="MenuItem_Click"/>
                <myMenu:PopupMenuItem x:Name="EditJob" Header="Edit a Job" Click="MenuItem_Click"/>
              </ListBox>
            </myMenu:PopupMenu>
            <myMenu:PopupMenuSeparator />
          </myMenu:PopupMenuItem>
          <myMenu:PopupMenuItem Header="Projection" ImageRightSource="../images/arrow.png">
            <myMenu:PopupMenu>
              <ListBox Style="{StaticResource MenuStyle1}" ItemContainerStyle="{StaticResource MenuItemContainerStyle1}">
                <myMenu:PopupMenuItem x:Name="JobPPUsage" Header="Job PP Usage" Click="MenuItem_Click"/>
                <myMenu:PopupMenuItem x:Name="JobProjection" Header="Job Projection" Click="MenuItem_Click" />
              </ListBox>
            </myMenu:PopupMenu>
          </myMenu:PopupMenuItem>
          <myMenu:PopupMenuSeparator />
          <myMenu:PopupMenuItem Header="Users" ImageRightSource="../images/arrow.png">
            <myMenu:PopupMenu>
              <ListBox Style="{StaticResource MenuStyle1}" ItemContainerStyle="{StaticResource MenuItemContainerStyle1}">
                <myMenu:PopupMenuItem x:Name="ManageUsers" Header="Manage Users" Click="MenuItem_Click"/>
                <myMenu:PopupMenuItem x:Name="UserRoles" Header="User Roles" Click="MenuItem_Click"/>
                <myMenu:PopupMenuItem x:Name="NewUser" Header="New User" Click="MenuItem_Click"/>
              </ListBox>
            </myMenu:PopupMenu>
          </myMenu:PopupMenuItem>
        </ListBox>
      </myMenu:PopupMenu>
    </StackPanel>
  </Grid>
</navigation:Page>

namespace AgmaSL5
{
    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Navigation;
    using SL4PopupMenu;

    /// <summary>
    /// Home page for the application.
    /// </summary>
    public partial class Administrator : Page
    {
        string AccessShortcut = "";
        public Administrator()
        {
            InitializeComponent();
            this.Title = ApplicationStrings.AdministratorPageTitle;
        }

        /// <summary>
        /// Executes when the user navigates to this page.
        /// </summary>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            PopupMenu.AccessShortcut = "Ctrl+Alt+M";
            PopupMenu.Visibility = System.Windows.Visibility.Visible;
        }

        private void MenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var pmiClicked = sender as PopupMenuItem;
            if (pmiClicked != null)
            {
                String nUri = String.Format("/{0}", pmiClicked.Name);
                MessageBox.Show(String.Format("/{0}", pmiClicked.Name), "Going To", MessageBoxButton.OK);
                PopupMenu.Visibility = System.Windows.Visibility.Collapsed;
                NavigationService.Navigate(new Uri(nUri, UriKind.Relative));
            }
        }
    }
}

Coordinator
Jul 8, 2011 at 3:16 AM
Edited Jul 8, 2011 at 6:02 AM

Hmm...here's what I can suggest so far from your XAML:

1. The AccessKeyTargetName property needs to be set for the menu to respond properly(this is no longer required in the latest release though).

2. Consider moving the first PopupMenuSeparator up in the tree.

3. Remove the style for the parent PopupMenu(Style="{StaticResource PopupMenuWithBorderMaskStyle1}") since you most probably won't need a border mask right now.

4. You don't need to set the visibility for the menu in code. The latter handles it automatically.

5. Setting visual properties like BorderBrush="RoyalBlue" and BorderThickness="8" on the PopupMenu have no effect at runtime. You will want to use the ListBox for this.

6. OpenOnAccessKeyPressed="True" and Orientation="Bottom" don't need to be specified since they are both defaults.

By the way v2.6.4 is out already and its got a few bug fixes that might be helpful in your case. So I strongly recommend it!

Hope this helps.

Ziad

Jul 8, 2011 at 8:23 AM

Again, Ziad, you continue to amaze and please this audience!

Your Points:

1. 'AccessKeyTargetName' is one of those properties that prompted my original query, i.e., what is it, what does it do? etc.  And what should it be set to?  Circuitous!  But in a search for the word I found it in the SL4PopupMenu base with a helpful comment, and set it up accordingly.

2. I moved the separator as recommended.

3. I removed the style as recommended.

4. I removed setting .visibility from .xaml.cs as recommended.

And now the menu works well but is only visible when I click the button (the 'AccessKeyTargetName').  While this is acceptable, I was hoping to have a static menu on the page.

 

Thank You, Ziad

Jack Webb

Coordinator
Jul 8, 2011 at 2:22 PM
Edited Jul 8, 2011 at 2:24 PM

The IsPinned property prevents the menu from closing. To open the menu however you can make use of the OpenNextTo method from code behind.

I haven't thought of implementing this in XAML even though this shouldn't be too difficult. So if you're badly in need of this feature please let me know and I'll fit it in the next release.

Regards

Ziad

Jul 8, 2011 at 10:50 PM

Ok, you got me.  I found the OpenNextTo method, and in the .xaml.cs OnNavigatedTo handler I had

PopupMenu.OpenNextTo(MenuOrientationTypes.Right, MenuItem, true, true);

and

PopupMenu.IsPinned = true;

What I got was the menu showing up in the upper left corner of the screen (to the right of the page header), and the menu was not operational.

So I'm Lost.  Yet one more time!

Coordinator
Jul 9, 2011 at 11:53 PM
Edited Jul 14, 2011 at 1:50 PM

This usually happens when the OpenNextTo method is called before the page is loaded or navigated to.

But now that I got your point I realize you don't need to create the Data, Projection and Users menus as PopupMenuItems and there is no need to make them part of yet another PopupMenu. Therefore a plain ListBox for the main menu and plain ListBoxItems for the menu items would do instead.

In brief you will want to wrap a content with a PopupMenu only if is meant to be hidden from the default page layout.

Regards

Ziad