Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6244585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:21:06+00:00 2026-05-24T12:21:06+00:00

I need a global context menu style / template having a header and then

  • 0

I need a global context menu style/template having a header and then various menu items; as the number of menu items in my context menu can be large it needs to support the scrolling.

The problem with current style I have is that it does not support the scrolling; even when the number of menu items grows past the screen size no scroll bar is displayed.

Here is the current style I am using –

<Style
    TargetType="{x:Type ContextMenu}"
    x:Key="ContextMenuStyle">
    <Setter
        Property="ContextMenu.Template">
        <Setter.Value>
            <ControlTemplate>
                <Border
                    BorderBrush="#868686"
                    BorderThickness="1"
                    Background="#FAFAFA">
                    <StackPanel
                        Orientation="Vertical">
                        <Label
                            Foreground="White"
                            Background="Blue">
                            <Binding
                                RelativeSource=
                                              "{RelativeSource AncestorType=
                                                {x:Type ContextMenu}}"
                                Path="PlacementTarget.Tag" />
                        </Label>
                        <Grid>
                            <Rectangle
                                Margin="1,1,1,1"
                                Width="25"
                                HorizontalAlignment="Left"
                                Fill="#E9EEEE" />
                            <Rectangle
                                Margin="26,1,0,1"
                                Width="1"
                                HorizontalAlignment="Left"
                                Fill="#C5C5C5" />
                            <Rectangle
                                Margin="27,1,0,1"
                                Width="1"
                                HorizontalAlignment="Left"
                                Fill="#FAFAFA" />
                            <ScrollViewer
                                Margin="1,0,1,0"
                                Style="{DynamicResource 
                                         {ComponentResourceKey                
                                         ResourceId=MenuScrollViewer,  
                                         TypeInTargetAssembly=
                                         {x:Type FrameworkElement}}}"
                                CanContentScroll="True"
                                Grid.ColumnSpan="2">
                                <ItemsPresenter
                                    KeyboardNavigation.DirectionalNavigation=
                                    "Cycle" />
                            </ScrollViewer>
                        </Grid>
                    </StackPanel>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Placing hte scroll viewer above header works but then header is also scrolled.

What is the best way to achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:21:07+00:00Added an answer on May 24, 2026 at 12:21 pm

    Try it like this instead. Changed the Vertical StackPanel (which doesn’t restrict the Height) to a Grid with two RowDefinitions (Auto, *)

    <Style TargetType="{x:Type ContextMenu}">
        <Setter Property="ContextMenu.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Border BorderBrush="#868686"
                            BorderThickness="1"
                            Background="#FAFAFA">
                        <Grid VerticalAlignment="Stretch">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Label Grid.Row="0" Foreground="White" Background="Blue">
                                <Binding RelativeSource= "{RelativeSource AncestorType= {x:Type ContextMenu}}" Path="PlacementTarget.Tag" />
                            </Label>
                            <Grid Grid.Row="1">
                                <Rectangle Margin="1,1,1,1"
                                            Width="25"
                                            HorizontalAlignment="Left"
                                            Fill="#E9EEEE" />
                                <Rectangle Margin="26,1,0,1"
                                            Width="1"
                                            HorizontalAlignment="Left"
                                            Fill="#C5C5C5" />
                                <Rectangle Margin="27,1,0,1"
                                            Width="1"
                                            HorizontalAlignment="Left"
                                            Fill="#FAFAFA" />
                                <ScrollViewer Margin="1,0,1,0"
                                                Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}"
                                                CanContentScroll="True"
                                                Grid.ColumnSpan="2">
                                    <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Cycle" />
                                </ScrollViewer>
                            </Grid>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

need to implement a global error handling, so maybe you can help out with
I need a way to stash some data that is global to the browser.
I need a big null array in C as a global. Is there any
I have a vector declared as a global variable that I need to be
VB 6.0 does not have any global handler.To catch runtime errors,we need to add
I've created a global handler for ajaxSuccess , but I need to be able
Need to locate the following pattern: The letter I followed by a space then
I'm having some problems with the global JNDI names of my EJB resources which
I have a multiple contexts running in one tomcat instance each context need access
I have a template that gets screenscraped from an outside vendor and need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.