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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:11:41+00:00 2026-05-20T06:11:41+00:00

I have a DataGrid in a UserControl and I have added a ContextMenu to

  • 0

I have a DataGrid in a UserControl and I have added a ContextMenu to the DataGrid.

The XAML is as follows:

<sdk:DataGrid ItemsSource="{Binding Path=GridSource}">
    <sdk:DataGrid.Columns>
        <sdk:DataGridTextColumn Binding="{Binding Path=Name, Mode=OneWay}" Header="Name"/>
        <sdk:DataGridTextColumn Binding="{Binding Path=Number, Mode=OneWay}" Header="Number"/>
    </sdk:DataGrid.Columns>
    <toolkit:ContextMenuService.ContextMenu>
        <toolkit:ContextMenu Opened="ContextMenu_Opened">
            <toolkit:MenuItem IsEnabled="False">
                <toolkit:MenuItem.Icon>
                    <Image x:Name="menuIcon"/> 
                </toolkit:MenuItem.Icon>
            </toolkit:MenuItem>
            <toolkit:Separator />
            <toolkit:MenuItem Header="View Agent Route" Click="AgentRoute_Click"/>
            <toolkit:MenuItem Header="Live Track" Click="LiveTrack_Click"/>
        </toolkit:ContextMenu>
    </toolkit:ContextMenuService.ContextMenu>
</sdk:DataGrid>

If I set the source of the menuIcon Image in XAML using

<Image x:Name="menuIcon" Source="../../Assets/Images/user_green.png"/>

Then the icon is rendered fine but if I try to set it in the ContextMenu_Opened event handler using:

private void ContextMenu_Opened(object sender, RoutedEventArgs e)
{
  menuIcon.Source = new BitmapImage(new Uri("../../Assets/Images/user_green.png", UriKind.Relative));
}

Nothing shows up, I don’t get an error or anything it just doesn’t show. I’ve used the same method to set an ImageSource (using the same actual *.png files) elsewhere in my application, any ideas what’s happening here?

Is this due to it being a ContextMenu? On a grid? I can’t figure out what’s going on.

  • 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-20T06:11:42+00:00Added an answer on May 20, 2026 at 6:11 am

    I got this one working by using a ImageSourceConverter within the contextmenu_opened event.

    private void ContextMenu_Opened(object sender, RoutedEventArgs e)
    {
      ImageSourceConverter converter = new ImageSourceConverter();
      menuIcon.Source = (ImageSource)converter.ConvertFromString("../../Assets/Images/user_green.png");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGrid defined as follows as part of a UserControl: <DataGrid x:Name=dtGrid
I have the following XAML: <UserControl.Resources> <local:MainPageViewModel x:Key=ViewModel /> </UserControl.Resources> <Grid x:Name=LayoutRoot DataContext={Binding Source={StaticResource
In application i have usercontrol with datagrid in it. For some columns i set
In my MainWindow.xaml, I have added my UserControl to the Window. There is also
I have a DataGrid with 5 template columns, However when I try and add
I have a DataGrid whose ItemsSource is bound to a changing Observable Collection. Inside
I have a datagrid called DataGridView1, column A contains a name, column B contains
I have a DataGrid with two way binding and not sure why this does
I have created usercontrol GridEx:UserControl. On that control I putted GridControl (DevExpress datagrid control).
I have declared a DataGrid in UserControl. Now I have included the UserControl in

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.