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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:20:52+00:00 2026-05-19T03:20:52+00:00

In my View, which is a UserControl I have a ListView which has a

  • 0

In my View, which is a UserControl I have a ListView which has a number of GridViewColumns, and i was wondering if it is possible to bind the first GridViewColumns to the ImageTypes Get/Set Property in my ViewModel and the other two columns to another WorkflowData GetSet property in the ViewModel?

The reason for this is my first column will come from a list of images, and the other columns come from data stored in my database.

At the moment I cannot seem to find the correct bindings to get the Icons to appear in a list with the other data coming from the Model (via ViewModel). Do i need to set the “RelativeSource” in the binding for the Image?

From my example you will see i am simple trying to show one image for now by passing the uri as a string.

Any help will be appreciated.
Thanks

XAML View snippet

<UserControl x:Class="Project.View.WorkflowStatus"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mvvmtk="clr-namespace:MVVMToolkit"
    Height="Auto"        
    xmlns:local="clr-namespace:Project.ViewModel">   
<UserControl.DataContext>
    <local:WorkflowStatusViewModel />
</UserControl.DataContext>
<ListView Grid.Column="0" Grid.Row="1" 
    ItemsSource="{Binding Path=WorkflowData.WFTasks, Mode=TwoWay}"
            SelectedValue="{Binding Workflow.WFTask}"
            HorizontalContentAlignment="Stretch">
    <ListView.View>
        <GridView>
                <GridViewColumn Header="" >
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Image Source="{Binding ImageTypes, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type local:WorkflowStatusViewModel}}}"
                                        Stretch="None"></Image>
                            </Grid>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
                <GridViewColumn Header="Field1"
                                Width="50"
                                DisplayMemberBinding="{Binding Path=Field1Value1}"></GridViewColumn>
                <GridViewColumn Header="Field2"
                                Width="50"
                                DisplayMemberBinding="{Binding Path=Field1Value2}"></GridViewColumn>
        </GridView>
    </ListView.View>            
</ListView>
</UserControl>

View Model Snippet

/// <summary>
// This is the main class which links the Model and View together.
/// </summary>
public class WorkflowStatusViewModel
{


    /// <summary>
    // Create a public instance of the workflow Model
    /// </summary>
    public WorkflowModel WorkflowData { get; set; }


    /// <summary>
    /// Class Constructor
    /// </summary>
    public WorkflowStatusViewModel()
    {
        InitialiseData();
    }


    ///MatterManagerView;component/Assets/Task.png
    private string _ImageTypes;
    public string ImageTypes
    {
        get { return "Project;component/Assets/Task.png"; }
        set { _ImageTypes = value; }
    }

    /// <summary>
    // Private function that create all the neccessary objects
    /// </summary>
    private void InitialiseData()
    {

        try
        {
            // Create a new instance of the Workflow Model
            WorkflowData = new WorkflowModel();

        }

        // Write Errors captured to Aderant Logging object
        catch (Exception ex)
        {


        }

    }

EDIT: Based on Marcel’s suggestion i tried to Map the Image using RelativeSource

  • 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-19T03:20:53+00:00Added an answer on May 19, 2026 at 3:20 am

    Yes, it can be done via RelativeSource

    The listview datacontext points to WorkflowData.WFTasks, but I expect the viewmodel itselfs bound to the page on which the listview is placed.
    Otherwise you should change the AncestorType

    After making a test project, the binding for you image column is:

    Source="{Binding Path=DataContext.ImageTypes, 
             RelativeSource={RelativeSource FindAncestor, 
             AncestorType={x:Type UserControl}}}"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a list view which has several rows of data and I
I have two resources Dock and Undock in my View which is a UserControl(Dock.xaml),
I have a view which contains a form, the form posts and the data
I have an ASP.NET MVC view which contains checkboxes for user-defined categories. <td><% foreach
I have an application, built using MVC, that produces a view which delivers summary
I have a list view control which at the moment only allows one item
I have a strongly-typed MVC View Control which is responsible for the UI where
Here is the problem: I have a ListView as following: <UserControl.Resources> <DataTemplate x:Key="FirstCell"> <StackPanel
I have a List View in which I have defined a custom cell as
I have a UserControl which contains a listbox and few buttons. <UserControl x:Class=ItemControls.ListBoxControl xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation

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.