Vectorlight News

  • Chat App Converted to HTML and JQuery
    Sep 08, 2011

    Converted from Silverlight to HTML and Javascript/JQuery is the Vectorlight Chat App. Login using your Vectorlight password to chat using your username and avatar.

  • HTML5 iPhone,Android Big Guns Tower Defense
    Jul 02, 2011

    Big Guns has made the leap from Windows Phone 7 (XNA) to HTML5 so you can now play it on your iPhone, Android and other HTML5 compatible devices.

  • HTML5 Games - Word Poppers and Batty
    Jun 04, 2011

    As the take-up of HTML5 quickens (74% of users currently have a browser capable of HTML5 Canvas) we present two more games for both your browser and mobile.

  • Big Guns Tower Defense on Windows Phone 7
    May 06, 2011

    Coming soon to Windows Phone 7 is an XNA port of the popular Vectorlight tower defense game Super Tower Defense. Whilst retaining many of the graphical and gameplay features of the original Silverlight game.

  • Wakacube WP7 Update
    Apr 26, 2011

    Released to the Windows Phone 7 marketplace today is Version 1.1 of Wakacube the 3D physics game of skill. Included in the update are more levels (30 in total) and new mode Wakatime which generates random crate structures to keep players entertained long after the levels have been completed.

  • Home Page News
cwright
cwright
howto: popup menu position using grid as layoutroot Posted: Feb 15, 2011
 

If you use a canvas to show the liquid menu, it's easy:


            Point p = e.GetPosition(this);

            Canvas.SetLeft(popupMenu, p.X);

            Canvas.SetTop(popupMenu, p.Y);

            popupMenu.Show();

            e.Handled = true;


If you use a grid however, you can't use Canvas.SetLeft e.t.c, so do something like this instead:


            Point p = e.GetPosition(LayoutRoot);


            popupMenu.SetValue(MarginProperty,

                new Thickness(

                    p.X,

                    p.Y,

                    ((ActualWidth - p.X)-140),

                    ((ActualHeight - p.Y)- 30)));

            popupMenu.Show();

            e.Handled = true;


140 & 30 is the size of my menu "box", there may be a better way to pass those parameters in, or even a better way to do the whole thing, but I couldn't see any samples on this site showing how to "show a popup in the right place" if you're using a grid as your layoutroot - so I hope this helps someone.

 
 
dan
dan
RE: howto: popup menu position using grid as layoutroot Posted: Mar 05, 2011
 

Hi,


Thanks for sharing this.  Having looked at this myself the best way to position a popup menu or anything else you want to popup I think is to use the TranslateTransform property:


<Grid x:Name="LayoutRoot" Background="White">

    <liquidMenu:Menu x:Name="myMenu" HorizontalAlignment="Left" VerticalAlignment="Top">

        <liquidMenu:Menu.RenderTransform>

            <TranslateTransform x:Name="myMenuTranslation" X="100" Y="100" />

        </liquidMenu:Menu.RenderTransform>

            

        <liquidMenu:MenuItem ID="undo" Shortcut="Ctrl+Z" Text="Undo" />

        <liquidMenu:MenuItem ID="redo" Shortcut="Ctrl+Y" Text="Redo" />

        <liquidMenu:MenuDivider />

        <liquidMenu:MenuItem ID="cut" Shortcut="Ctrl+X" Text="Cut" />

        <liquidMenu:MenuItem ID="copy" Shortcut="Ctrl+C" Text="Copy" />

        <liquidMenu:MenuItem ID="paste" Shortcut="Ctrl+V" Text="Paste" />

    </liquidMenu:Menu>

</Grid>


Changing the HorizontalAlignment="Left" VerticalAlignment="Top" means you will not have to specify a width/height on your menu, without these the menu would stretch.

To control the X/Y position you would do something like this:


myMenuTranslation.X = newX;

myMenuTranslation.Y = newY;


You could use this no matter what your popup is contained within.  Whether it's a Grid or Canvas it will work the same.  Hope this helps.


Thanks! Dan