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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:50:49+00:00 2026-05-31T04:50:49+00:00

I have a problem with my data binding, probably a small one. I have

  • 0

I have a problem with my data binding, probably a small one. I have tried to implement the MVVM pattern in my application. Therefore I have a model containig my data. This data gets updated over the network in a periodic way. On top of this model I have a view model to bind to. In this view model I have a ObservableCollection, which I want to bind. The problem I have is, that my view model needs to be a global resource. Thats why I use the following attempt in my NavigationWindow :

<NavigationWindow.DataContext>
    <localvm:DataViewModel/>
</NavigationWindow.DataContext>

The reason I have to use it as a global variable is, that this view model starts my network business logic. Thats probably a bad way but I could’nt find a solution to this. Anyway
to diplay my data I have a Frame in my NavigationWindow defined like this:

<Frame Source="/Views/Pages/Page1_SystemOverview.xaml" VerticalAlignment="Stretch></Frame>

in this loaded page I have a ItemsControl to view the Collection:

<Page>
<Grid>
    <Grid.Resources>
        <localcnv:DebugHelperConverter x:Key="debugCNV"/>
    </Grid.Resources>
    <StackPanel>
        <ItemsControl ItemsSource="{Binding Source=ListOfQuerys}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Vertical"></StackPanel>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>

        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <StackPanel>
                        <Button Content="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=(ItemsControl.AlternationIndex)}"/>
                </StackPanel>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
    </StackPanel>   
</Grid>

So here is my problem: When I start my program The ItemsControl contains 18 elements with no content at all. It should contain only two elements, the output window shows me no binding errors, but when I change the ItemsSource to

"{Binding Path=ListOfQuerys}"

it says:

System.Windows.Data Information: 41 : BindingExpression path error: 'ListOfQuerys' property not found for 'object' because data item is null.  This could happen because the data provider has not produced any data yet. BindingExpression:Path=ListOfQuerys; DataItem=null; target element is 'ItemsControl' (Name=''); target property is 'ItemsSource' (type 'IEnumerable')

What am I doing wrong? I thought, when I set the DataContext in a parent class, I can use it down the tree but somehow it won’t work, any Ideas?

Thanks!

  • 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-31T04:50:50+00:00Added an answer on May 31, 2026 at 4:50 am

    The content of the Frame element is not part of visual / logical tree and hence will not persist the data context. You will have to set it explicitly.

        <Frame Source="Page1.xaml" Navigated="Frame_Navigated"/>
    
        private void Frame_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
        {
            ((FrameworkElement) e.Content).DataContext = this.DataContext;
        }
    

    Hope this helps…

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

Sidebar

Related Questions

I have have a problem with data binding. I have defined a application resource
I have a problem with binding data using BindingSource, typed dataset and DataGridView. My
I am a learner and i have a problem data binding the dataset. Please
I am having major problem in Data Binding. I have a stackpanel with an
In my MVC application I have a problem with passing data from view to
I have a problem when binding the data in gridview. I am attempting to
Hi I have a little problem. I'm using data binding to retrieve data from
I have a grid view which I am binding with data table. My problem
I have problem with adding image to DGV cell after data binding. this is
The Dropdownlist data binding using throw common function. In this have a problem 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.