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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:42:21+00:00 2026-05-27T02:42:21+00:00

I can’t find an event that can be called after a window was loaded,

  • 0

I can’t find an event that can be called after a window was loaded, and where i can get access to the ItemsSource of a ListView. The only thing i can think is the Loaded event in the ListView but when this event is fired the ItemsSource remains null.

I probably need another event so i can know what is in the ItemsSource.

So with code i will probably expose better what i am trying to do:

In a custom class:

public class GridViewSomething
{
    public static readonly DependencyProperty TestProperty =
        DependencyProperty.RegisterAttached("Test",
        typeof(bool),
        typeof(GridViewSomething),
        new UIPropertyMetadata(OnTestChanged));

    public static bool GetTest(DependencyObject obj)
    {
        return (bool)obj.GetValue(TestProperty);
    }

    public static void SetTest(DependencyObject obj, bool value)
    {
        obj.SetValue(TestProperty, value);
    }

    static void OnTestChanged(object sender, DependencyPropertyChangedEventArgs e)
    {
        ListView listView = sender as ListView;

        if (!(bool)e.OldValue && (bool)e.NewValue)
            listView.AddHandler(ListView.LoadedEvent, new RoutedEventHandler(ListView_Loaded));
        else if (!(bool)e.NewValue && (bool)e.OldValue)
            listView.RemoveHandler(ListView.LoadedEvent, new RoutedEventHandler(ListView_Loaded);
    }

    static void ListView_Loaded(object sender, RoutedEventArgs e)
    {
        ListView listView = sender as ListView;

        if (listView.ItemsSource != null)
        {
            //Do some work
        }
    }
}

And the ListView:

(...)

<ListView ItemsSource="{Binding Students}"
          test:GridViewSomething.Test="True">

(...)

I am binding the ListView to a Collection in the ViewModel of this Window. I need to know precisely what is in the ItemsSource in that custom class.

So how i can achieve this?

Thanks in advance!

  • 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-27T02:42:21+00:00Added an answer on May 27, 2026 at 2:42 am

    You could subsribe to changes on the ItemsSource property by using a descriptor as shown here. If check the value in that handler it should not be null (unless the bound property was in fact set to null).

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

Sidebar

Related Questions

Can a LINQ enabled app run on a machine that only has the .NET
Can some one confirm me that only one UIWindow instance is possible in any
Can somebody point me to a resource that explains how to go about having
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can I get a 'when to use' for these and others? <% %> <%#
Can I call select before recv_from on a socket that is blocking?
Can anybody tell me a regular expression to use within some PHP to find
Can I have a project that has some parts written in c and other
Can i get the source code for a WAMP stack installer somewhere? Any help
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.