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

  • Home
  • SEARCH
  • 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 974359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:25:30+00:00 2026-05-16T03:25:30+00:00

I templated the way items shows up in a menu, but, for an unknown

  • 0

I templated the way items shows up in a menu, but, for an unknown reason, I am having trouble displaying the whole text in the MenuItem. Here is a screen capture of the problem:
alt text http://img203.imageshack.us/img203/4513/capturexz.png

Here is the markup code I used to template it:

<ItemsPanelTemplate x:Key="SideBarItemsPanelTemplate">
    <StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
<DataTemplate x:Key="SideBarItemTemplate">
    <MenuItem Command="{Binding}" Header="{Binding Text}" Background="AliceBlue">
        <MenuItem.Icon>
            <Image Width="16" Height="16" Source="{Binding Image}"/>
        </MenuItem.Icon>
    </MenuItem>
</DataTemplate>
<Style x:Key="SideBarStyle" TargetType="{x:Type Menu}">
    <Setter Property="ItemTemplate" Value="{StaticResource SideBarItemTemplate}"/>
    <Setter Property="ItemsPanel" Value="{StaticResource SideBarItemsPanelTemplate}"/>
    <Setter Property="Background" Value="White"/>
</Style>

And to display it:

<Menu ItemsSource="{Binding Commands}" Style="{StaticResource SideBarStyle}"/>

I searched a lot, but nothing helped solving this issue. Hope I will find some help here.

Thanks.

  • 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-16T03:25:30+00:00Added an answer on May 16, 2026 at 3:25 am

    You’re getting weird behavior because you have a MenuItem within a MenuItem. By setting the ItemTemplate on the Menu, you’re setting the HeaderTemplate on each MenuItem. The MenuItem will render its normal template, and where the header text would normally be placed it will have an entire other MenuItem. I think the space you see is the space reserved for the InputGestureText in the outer MenuItem.

    Instead, you want to set an ItemContainerStyle. This will let you set properties on the MenuItems created by the Menu. There is one trick you need to use so that you can create a separate Image object for each MenuItem. By default, objects included in a Style will be shared, and you will get one Image object shared by every MenuIte, but if you put them in a separate resource dictionary you can mark them as not shared. See this issue on Connect and the linked workaround.

    Something like this:

    <Style x:Key="SideBarStyle" TargetType="{x:Type Menu}">
        <Setter Property="ItemsPanel" Value="{StaticResource SideBarItemsPanelTemplate}"/>
        <Setter Property="Background" Value="White"/>
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="MenuItem">
                    <Style.Resources>
                        <ResourceDictionary Source="Icon.xaml"/>
                    </Style.Resources>
                    <Setter Property="Command" Value="{Binding}"/>
                    <Setter Property="Header" Value="{Binding Text}"/>
                    <Setter Property="Background" Value="AliceBlue"/>
                    <Setter Property="Icon" Value="{StaticResource Icon}"/>
                </Style>
            </Setter.Value>
        </Setter>
    </Style>
    

    Where Icon.xaml contains:

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <Image x:Key="Icon" x:Shared="False" Width="16" Height="16" Source="{Binding Image}"/>
    </ResourceDictionary>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to do a basic search feature but I am having a
I am new to extjs and I am having trouble when feeding a template
Here's the view.py. show_checkout is called and runs all the way to return HttpResponseRedirect('/receipt/')
Ok, sounds odd, and there's likely a better way, but I haven't seen it
I am trying to specialize template the following way: template<size_t _1,size_t _2> // workaround:
Is it possible to generate some parts of TypoScript templates in dynamic way ?
What is the fastest way to store templates? In a database (SQL Server) or
Is there any way to have a template inherit another template? I'm not using
Is there a way for taking type of a template class, for example //i
Can someone suggest me a way to map a template classes with a set

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.