Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to code a menu un a browser
Message
From
24/02/2010 03:26:27
 
 
To
23/02/2010 20:36:23
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Environment versions
Environment:
VB 9.0
Miscellaneous
Thread ID:
01450668
Message ID:
01450691
Views:
54
>Hello
>I am using vb express 2008
>Can anybody explain how is the sintax to make a code for Menu in a browser in XAML?
>Thank you in advance
>Luis Martin

Hi,
Menus are pretty flexible in WPF. Example of some of the options (just scratching the surface really):
<Window x:Class="Junk.Window2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="300" Width="300">
    <StackPanel>
        <Menu>
            <MenuItem Header="File" >
                <!--Normal Click handling -->
                <MenuItem Header="Open" Click="MenuItem_Click"/>
                <!--Wired to WPF RoutedUICommand
                (Note Header and ShortCut are supplied by the command)-->
                <MenuItem Command="ApplicationCommands.Save"/>
                <!-- Checkable Example-->
                <MenuItem Header="DoIt?" IsCheckable="True" Foreground="Red"/>
            </MenuItem>
            <MenuItem Header="Edit">
                <MenuItem Header="Name">
                    <!-- MenuItem can be anything....-->
                    <StackPanel Orientation="Horizontal">
                        <TextBox Width="100"></TextBox>
                        <Button>Save</Button>
                    </StackPanel>
                </MenuItem>
            </MenuItem>
        </Menu>
        <StackPanel>
            <TextBox Width="200" Height="200"></TextBox>
            <!-- A Menu can be anywhere-->
            <Menu>
                <MenuItem Header="Hello"/>
            </Menu>
        </StackPanel>
    </StackPanel>
</Window>
The most flexible approach is to wire up the items using the Commanding system. You can either use the pre-defined WPF commands as in the above "Save" item or author your own additions. If you want to get fancy bear in mind that MenuItem derives from FrameworkElement so you can not only set colors as above but also use animation, mouseover etc etc
HTH,
Viv
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform