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 340561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:37:39+00:00 2026-05-12T10:37:39+00:00

I have a XAML MenuItem DataBound ItemsSource that is working fine however there is

  • 0

I have a XAML MenuItem DataBound ItemsSource that is working fine however there is a small issue. When I view the MenuItem and there is no databound items the ParentMenu will be disabled and it appears fine without binding errors (as expected the ItemsSource is empty). If the ObservableCollection is modified and an item added, the binding refreshes and the MenuItem appears. However the ItemContainerStyle doesn’t upodate the MenuItem.Tag property to the databound value.

The MenuItem works fine as long as the ItemsSource never starts as empty or is never reduced to empty. Does anyone have any tips for such an issue? I would like to have the ItemsSource and ItemContainerStyle refresh correctly at all times even when the ItemsSource starts as empty

XAML is shown below:

<MenuItem x:Name="MenuItem" Header="Menu" ItemsSource="{Binding Source={StaticResource MenuItemViewSource}}" ItemTemplate="{StaticResource MenuDataTemplate}">
    <MenuItem.ItemContainerStyle>
        <Style TargetType="{x:Type MenuItem}">
            <Setter Property="Tag" Value="{Binding Path=ID, Source={StaticResource MenuItemViewSource}}"/>
            <Setter Property="Background" Value="Red"/>
            <Setter Property="Opacity" Value="0.5"/>
            <EventSetter Event="Click" Handler="MenuItem_Click"/>
        </Style>
    </MenuItem.ItemContainerStyle>
    <MenuItem.Style>
        <Style TargetType="{x:Type MenuItem}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=Items.Count, RelativeSource={RelativeSource Self}}" Value="0">
                    <Setter Property="IsEnabled" Value="False"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </MenuItem.Style>
</MenuItem>
  • 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-12T10:37:39+00:00Added an answer on May 12, 2026 at 10:37 am

    Just a guess, but have you tried binding to the ID of the underlying data without setting the binding’s DataSource to the view source? Like this:

    <Setter Property="Tag" Value="{Binding ID}"/>
    

    A binding like that within a style should bind to the DataContext of the MenuItem itself, which is the item that the MenuItem represents. Binding back to the view source like you’re doing might be confusing it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have in XAML 3 menu items defined (using WPF-MDI): <MenuItem Header=_Generic Name=Generic ToolTip=Generic
I have styled my Menu/ContextMenu/MenuItem controls in App.xaml so that those styles apply to
I have a .xaml file and a .cs file that share value with Binding.
I have a XAML file that I exported from Expression Design. I would like
I have a WPF application that I'm trying to dynamically add items to a
In my WPF application (XAML posted below), I have a List View and below
I have the following XAML: <dxg:GridControl Name=theGrid DataSource={Binding Path=Groupings}> <dxg:GridControl.ContextMenu> <ContextMenu> <MenuItem x:Name=gridprint Command={Binding
I have this XAML: <Window x:Class=WpfBindToCodeBehind.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=Window1 Height=300 Width=300 Loaded=Window_Loaded> <StackPanel Orientation=Vertical>
I have a xaml navigation page with 5 listboxes (Silverlight 3). Four of the
I have a xaml file with this code: <GridViewColumn x:Name=lvCol3 Header=Quantità Width=120> <GridViewColumn.CellTemplate> <DataTemplate>

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.