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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:36:48+00:00 2026-06-13T07:36:48+00:00

I have following ContextMenu in my xaml: <ContextMenu ItemsSource={Binding RSPContextMenuCommands}> <ContextMenu.ItemContainerStyle> <Style TargetType={x:Type MenuItem}>

  • 0

I have following ContextMenu in my xaml:

<ContextMenu ItemsSource="{Binding RSPContextMenuCommands}">
                        <ContextMenu.ItemContainerStyle>
                            <Style TargetType="{x:Type MenuItem}">
                                <Setter Property="CommandParameter" Value="{Binding}" />
                                <Setter Property="Command" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}, Path=DataContext.ShowASPCommand}" />
                                <Style.Triggers>                          
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding SpName}" Value="ASP">
                                        <Setter Property="Header" Value="Show Additional Service Providers" />
                                        <Setter Property="Command" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}, Path=DataContext.TransferCommand}" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </ContextMenu.ItemContainerStyle>
                        <ContextMenu.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Margin="5,0,0,0" Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}, Path=PhoneNumber, PresentationTraceSources.TraceLevel=High}" />
                                </StackPanel>
                            </DataTemplate>
                        </ContextMenu.ItemTemplate>
                    </ContextMenu>

where, RSPContextMenuCommands is collection of type Schedule(class). Schedule has PhoneNumber property in it.TransferCommand is at the same level where RSPContextMenuCommands is declared. I am getting ShowASPCommand and TransferCommand but NOT PhoneNumber. I tried various RelativeSource combinations but it didn’t work. what should be the proper RelativeSource for it. also tried RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}, Path=PhoneNumber

  • 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-06-13T07:36:49+00:00Added an answer on June 13, 2026 at 7:36 am

    workaround. I moved ItemTemplate above ItemContainerStyle.

    <ContextMenu ItemsSource="{Binding RSPContextMenuCommands}">
                            <ContextMenu.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding PhoneNumber}" />
                                    </StackPanel>
                                </DataTemplate>
                            </ContextMenu.ItemTemplate>
                            <ContextMenu.ItemContainerStyle>
                                <Style TargetType="{x:Type MenuItem}">
                                    Setter Property="Command" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}, Path=DataContext.ShowASPCommand, PresentationTraceSources.TraceLevel=High}" />
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding SpName}" Value="ASP">
                                         <Setter Property="Command" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}, Path=DataContext.TransferCommand}" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </ContextMenu.ItemContainerStyle>
                        </ContextMenu>
    

    But still if anyboday can provide me proper documentation for RelativeSource approach. I would really appreciate it. 🙂

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

Sidebar

Related Questions

I have the following XAML: <dxg:GridControl Name=theGrid DataSource={Binding Path=Groupings}> <dxg:GridControl.ContextMenu> <ContextMenu> <MenuItem x:Name=gridprint Command={Binding
My situation is like following. I have a App.xaml which includes Style for ListView
let's say I have following code : <ContextMenu IsEnabled={Binding Converter={StaticResource SomeConverterWithSmartLogic}}> So, I did
I have a ContextMenu with a MenuItem in it: <Grid> <Button Content={Binding Test}> <Button.ContextMenu>
I got the following code : <HierarchicalDataTemplate x:Key=AssignedRate ItemsSource={Binding Children} DataType={x:Type local:UnitRateCatElement}> <ContentControl> <ContentControl.Template>
I have the following piece of XAML code: <controlsInputToolkit:ContextMenuService.ContextMenu> <controlsInputToolkit:ContextMenu Height=75 Width=200 IsOpen=False Visibility=Collapsed
I have the following piece of XAML code: <controlsInputToolkit:ContextMenuService.ContextMenu> <controlsInputToolkit:ContextMenu Height=75 Width=200 IsOpen=False Visibility=Collapsed
I have the following button with associated context menu <div class=control-action> <button>Action</button> <ul style=display:none>
I have the following GridView : <ListView Name=TrackListView ItemContainerStyle={StaticResource itemstyle}> <ListView.View> <GridView> <GridViewColumn Header=Title
In a WPF app I have a ResourceDictionary with Style defined for the TargetType

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.