locked
how to make a context menu silverlight 2.0 in blend? RRS feed

  • Question

  • I am having a really hard time trying to figure out how to make a context/ pop up menu in a silverlight 2.0 applcation in blend 2.5 March. Can someone please help me? I thought I would just use the popup control but I do not understand how to use it. It looks like it has a grid in it. But when I add things to the grid nothing changes. It is just completely invisible.
    Designer Girl
    Wednesday, June 4, 2008 5:14 PM

Answers

All replies

  • You can get the content on the IE while runtime but not design time.

    Hope the following codes can help you

    XAML:
    <UserControl
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     x:Class="SilverlightApplication22.Page"
     Width="640" Height="480">

     <Grid x:Name="LayoutRoot" Background="White">
      <StackPanel Background="White">
                <Button Width="100" Height="50" x:Name="showPopup"
                Click="showPopup_Click" Content="Show Popup" />
            </StackPanel>
      <Popup Height="190" VerticalAlignment="Top" Margin="0,0,0,0" Width="165" HorizontalAlignment="Left" x:Name="PopupMenu">
       <Grid Height="165" Width="159" Background="#FFF60B0B">
        <Button Margin="0,0,59,65" Content="Button" Background="#FF0091F7" x:Name="Button1" Click="button1_Click" />
       </Grid>
      </Popup>
     </Grid>
    </UserControl>

    C#
      private void showPopup_Click(object sender, RoutedEventArgs e)
      {
       // Open the popup.
       PopupMenu.IsOpen = true;
      }

      void button1_Click(object sender, RoutedEventArgs e)
      {
       // Close the popup.
       PopupMenu.IsOpen = false;
      }

     

    Friday, June 6, 2008 9:33 AM
  • Can you please give me the complete C# page code? When I copy and paste your C# code into mine it gives me a ton of errors. Thank you!
    Designer Girl
    Tuesday, June 10, 2008 4:42 PM
  • Here is my C#

    using System;

    using System.Windows;

    using System.Windows.Controls;

    using System.Windows.Documents;

    using System.Windows.Ink;

    using System.Windows.Input;

    using System.Windows.Media;

    using System.Windows.Media.Animation;

    using System.Windows.Shapes;

    namespace popupTestDELETEME

    {

    public partial class Page : UserControl

    {

    public Page()

    {}

    // Required to initialize variables

    private void showPopup_Click(object sender, RoutedEventArgs e)

    {

    // Open the popup.

    PopupMenu.IsOpen = true;

    }

    void button1_Click(object sender, RoutedEventArgs e)

    {

    // Close the popup.

    PopupMenu.IsOpen = false;

    }



    }

    }


    Designer Girl
    Tuesday, June 10, 2008 4:47 PM
  • Can someone please help me with this? I am very confused...... I really need to know how to make a dropdown/pop up menu!
    Designer Girl
    • Edited by designerGirl Wednesday, June 25, 2008 1:53 PM to try and get help
    Wednesday, June 18, 2008 8:33 PM
  • Anyone?
    Designer Girl
    Wednesday, June 25, 2008 1:59 PM
  •  PROBLEM SOLVED!!! Thanks to Jeetendra! Go to this link to learn the solution:

    http://geekgirlblend.blogspot.com/2008/07/pop-up-or-drop-down-in-silverlight-20.html
    Designer Girl
    • Marked as answer by designerGirl Wednesday, July 16, 2008 2:05 PM
    Wednesday, July 16, 2008 2:05 PM