none
Does anybody know if Microsoft is actually going to fix ContextMenu?

Answers

  • Hi mtiede,

    I have written a sample code with the same features by Silverlight 5 and it runs well, you can compare with it.

    If your issue still exsist, please kindly share your code, thanks for understanding.

    Here is code below:

    //Page_Xaml
    <UserControl  x:Class="SilverlightApplication6.Views.ContextMenuPage"
        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:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400">
        <Grid x:Name="LayoutRoot" Background="White">
            <Button Click="Button_Click" Width="60" Height="20">Show</Button>
        </Grid>
    </UserControl>
    //Page_Code
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows;
    using System.Windows.Controls;
    using SilverlightApplication6.Controls;
    
    namespace SilverlightApplication6.Views
    {
        public partial class ContextMenuPage : UserControl
        {
            ChildWindow1 child = new ChildWindow1();
            public ContextMenuPage()
            {
                InitializeComponent();
            }
            private void Button_Click(Object sender, RoutedEventArgs e)
            {
                child.Show();
            }
        }
    }
    //ChildWindow_Xaml
    <controls:ChildWindow  x:Class="SilverlightApplication6.Controls.ChildWindow1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
        xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
        Width="400" Height="300" Title="ChildWindow1" DataContext="MyChildWindowDataContext">
        <Grid x:Name="LayoutRoot" Margin="2">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
            <Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
        </Grid>
        <toolkit:ContextMenuService.ContextMenu>
            <toolkit:ContextMenu x:Name="menu">
                <toolkit:MenuItem Header="Add" Click="MenuItem_Click" CommandParameter="{Binding}"></toolkit:MenuItem>
                <toolkit:MenuItem Header="Remove"></toolkit:MenuItem>
                <toolkit:MenuItem Header="Copy"></toolkit:MenuItem>
                <toolkit:MenuItem Header="Cut"></toolkit:MenuItem>
            </toolkit:ContextMenu>
        </toolkit:ContextMenuService.ContextMenu>
    </controls:ChildWindow>
    //ChildWindow_Code
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows;
    using System.Windows.Controls;
    
    namespace SilverlightApplication6.Controls
    {
        public partial class ChildWindow1 : ChildWindow
        {
            public ChildWindow1()
            {
                InitializeComponent();
            }
            private void OKButton_Click(Object sender, RoutedEventArgs e)
            {
                this.DialogResult = true;
            }
            private void CancelButton_Click(Object sender, RoutedEventArgs e)
            {
                this.DialogResult = false;
            }
            private void MenuItem_Click(Object sender, RoutedEventArgs e)
            {
                MenuItem item = sender as MenuItem;
                MessageBox.Show("parameter:" + item.CommandParameter);
            }
        }
    }

    If you want to define the ContextMenu at Page then you cannot use it while ChildWindow shows because it will cover page's layout. Wish that will help you.

    Monday, January 23, 2012 10:41 PM

All replies

  • I just looked in Connect and of the bugs for Silverlight in the last 90 days, I don't see ANY that are fixed.  Mostly they are closed as not reproducible, or as designed, won't fix, type responses.

    MAYBE there was one problem that was fixed with xaml display in VS.  Which is hardly SL.

    Saturday, January 21, 2012 8:10 AM
  • Well, I found where stuff is in Codeplex and it DOES look like some stuff is being fixed in there I guess.  Although only ONE thing was fixed since November of last 2011.

    Saturday, January 21, 2012 8:14 AM
  • Hi mtiede,

        For now the Silverlight 5 formal version has been published.You can download athttp://go.microsoft.com/fwlink/?LinkId=229318.

        Silverlight 5 Toolkit:http://silverlight.codeplex.com/.

        Regarding ContextMenu, you can see more information at http://msdn.microsoft.com/en-us/library/system.windows.controls.contextmenu.aspx.

        Wish that will help you.

     

    Sunday, January 22, 2012 10:33 PM
  • Nope, doesn't help.  I already HAVE SL 5 and I'm not sure why the .Net documentation for ContextMenu helps with a Silverlight ContextMenu class from the Toolkit.  But in any case, I'm familiar with the documenation.

    So doesn't anybody know the answers to my questions?

    Monday, January 23, 2012 7:32 AM
  • Hi mtiede,

    I have written a sample code with the same features by Silverlight 5 and it runs well, you can compare with it.

    If your issue still exsist, please kindly share your code, thanks for understanding.

    Here is code below:

    //Page_Xaml
    <UserControl  x:Class="SilverlightApplication6.Views.ContextMenuPage"
        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:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400">
        <Grid x:Name="LayoutRoot" Background="White">
            <Button Click="Button_Click" Width="60" Height="20">Show</Button>
        </Grid>
    </UserControl>
    //Page_Code
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows;
    using System.Windows.Controls;
    using SilverlightApplication6.Controls;
    
    namespace SilverlightApplication6.Views
    {
        public partial class ContextMenuPage : UserControl
        {
            ChildWindow1 child = new ChildWindow1();
            public ContextMenuPage()
            {
                InitializeComponent();
            }
            private void Button_Click(Object sender, RoutedEventArgs e)
            {
                child.Show();
            }
        }
    }
    //ChildWindow_Xaml
    <controls:ChildWindow  x:Class="SilverlightApplication6.Controls.ChildWindow1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
        xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
        Width="400" Height="300" Title="ChildWindow1" DataContext="MyChildWindowDataContext">
        <Grid x:Name="LayoutRoot" Margin="2">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
            <Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
        </Grid>
        <toolkit:ContextMenuService.ContextMenu>
            <toolkit:ContextMenu x:Name="menu">
                <toolkit:MenuItem Header="Add" Click="MenuItem_Click" CommandParameter="{Binding}"></toolkit:MenuItem>
                <toolkit:MenuItem Header="Remove"></toolkit:MenuItem>
                <toolkit:MenuItem Header="Copy"></toolkit:MenuItem>
                <toolkit:MenuItem Header="Cut"></toolkit:MenuItem>
            </toolkit:ContextMenu>
        </toolkit:ContextMenuService.ContextMenu>
    </controls:ChildWindow>
    //ChildWindow_Code
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows;
    using System.Windows.Controls;
    
    namespace SilverlightApplication6.Controls
    {
        public partial class ChildWindow1 : ChildWindow
        {
            public ChildWindow1()
            {
                InitializeComponent();
            }
            private void OKButton_Click(Object sender, RoutedEventArgs e)
            {
                this.DialogResult = true;
            }
            private void CancelButton_Click(Object sender, RoutedEventArgs e)
            {
                this.DialogResult = false;
            }
            private void MenuItem_Click(Object sender, RoutedEventArgs e)
            {
                MenuItem item = sender as MenuItem;
                MessageBox.Show("parameter:" + item.CommandParameter);
            }
        }
    }

    If you want to define the ContextMenu at Page then you cannot use it while ChildWindow shows because it will cover page's layout. Wish that will help you.

    Monday, January 23, 2012 10:41 PM
  • Thanks, I've got it working now.  Not sure why it didn't work before.  I think the behavior I found on the internet was not doing the right thing and I fixed it to work.

    Thursday, January 26, 2012 4:33 AM