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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:40:01+00:00 2026-05-28T07:40:01+00:00

I have an data transfer object called Report . These report objects are held

  • 0

I have an data transfer object called Report. These report objects are held in an observable collection in a different class called Controller. What I am trying to do is create a view that takes data from the Report and displays that in a list.

The problem I am having is that I cannot seem to bind the view properly to the view model. I managed to get it to bind by using a value converter and returning the viewmodel that I need but the Bindings do not seem to resolve even though the view is attached.

The viewmodel that contains the Report list:

public class ReportListViewModel : Screen, IModule
{
    private Controller _controller;
    public Controller Controller
    {
        get { return _controller; }
        set { _controller = value; }
    }

    public ReportListViewModel(Controller controller)
    {
        Controller = controller;
        Controller.Domain.Reports.Add(new Model.Report() { Notes = "Test Data.." });
    }
}

And the XAML view for it:

<Grid Background="Blue">
    <StackPanel>
        <StackPanel.Resources>
            <local:ReportToListItem x:Key="reportToListItem" />
        </StackPanel.Resources>
        <ListBox Height="100" x:Name="Controller_Domain_Reports">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <ContentControl Content="{Binding Converter={StaticResource reportToListItem}}"/>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </StackPanel>
</Grid>

The value converter:

internal class ReportToListItem : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        var vm = IoC.Get<ReportListItemViewModel>();
        vm.Report = (Report)value;
        var view = ViewLocator.GetOrCreateViewType(typeof(ReportListItemView));
        ViewModelBinder.Bind(vm, view, null);
        return view;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

And here are the viewmodel and view that are going to be responsible for displaying the data of the Report object.

Viewmodel:

public class ReportListItemViewModel : Screen
{
    private Report _report;
    public Report Report
    {
        get { return _report; }
        set { _report = value; }
    }
}

View:

<Grid>
    <TextBlock Text="{Binding Report, Path=Notes}" />
</Grid>

Now I know that the view is being attached because the OnViewAttached method of the ReportListItemViewModel is triggered. I know the view is being initialed too because it’s constructor is triggered.

But the getter on the ReportListItemViewModel.Report is never called.

So what is going wrong with the Binding?

  • 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-28T07:40:01+00:00Added an answer on May 28, 2026 at 7:40 am

    To load the view automatically with caliburn, you have to bind to Caliburn’s attached properties:

    <ContentControl cal:View.Model="{Binding ...}"/>
    

    Otherwise you won’t load the corresponding view into the content control but the viewmodel itself.

    Edit:

    The stuff above seems to be nonsense, since the OP says the view gets created, also I think I spotted the actual problem:

    If you set the binding like this:

    <TextBlock Text="{Binding Report, Path=Notes}" />
    

    it won’t work, since you are overwriting the path Report with Notes. To access the Notes property in Report, you have to specify the item like this:

    <TextBlock Text="{Binding Report.Notes}" />
    

    or like this:

    <TextBlock Text="{Binding Path=Report.Notes}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these data transfer objects: public class Report { public int Id {
see also Hows to quick check if data transfer two objects have equal properties
I have two Database, DB1 and DB2. How can I transfer data of DB1
One day I suspect I'll have to learn hadoop and transfer all this data
In reading about C#, I have come across the terms data transfer type and
I have a transfer object being returned to the JSP after a search. It
I'm trying to come up with a methodology for when to use Data Transfer
I know DTO is a data transfer object and a BO is a business
I have an ASP.NET MVC 2 project in which I've created a data transfer
How do I make transfer of a class object from one page to another

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.