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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:45:17+00:00 2026-05-27T18:45:17+00:00

I’m trying to build up a page that will show a progress bar until

  • 0

I’m trying to build up a page that will show a progress bar until the data is successfully downloaded from a server.

For this i use a Generic data downloader that will simply populate the Model’s properties and set the IsLoading property to true and/or false

The View models look like:

public class GenericPageModel: GenericModel
{
    private bool _isLoading;
    public bool IsLoading
    {
        get { return _isLoading; }
        set
        {
            _isLoading = value;
            OnPropertyChanged("IsLoading");
        }
    }
}

public class GenericModel :  INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;
    public void OnPropertyChanged(string propName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propName));
        }
    }
}

The GenericPageModel is used in a XAML page as a Model and the IsLoading property is used as bellow:

<Grid>
    <Grid.Resources>
        <BooleanToVisibilityConverter x:Key="boolToVis"/>            
    </Grid.Resources>
    <ProgressBar Height="25" Margin="5"
                 VerticalAlignment="Center" HorizontalAlignment="Stretch"
                 Visibility="{Binding IsLoading, Converter={StaticResource boolToVis}}"
                 IsIndeterminate="True"
    />
</Grid>

The generic data downloader:

...
// Model that it's calling this
public object Model
{ get; set; }

private string _loadingProperty;
...

void _bw_DoWork(object sender, DoWorkEventArgs e)
{
    // Set the is loading property
    if (null != _loadingProperty)
    {
        //((Model as GenericModel).Owner as GenericPageModel).IsLoading = true;  // Works!!
        Model.GetType().GetProperty(_loadingProperty).SetValue(Model, true, null); // Doesn't work
    }
 }

If i explicitly cast Model to the GenericPageModel and set the IsLoading to true, everything works just fine (see the commented line)

If i use reflection to set the Value of the property, the IsLoading setter is hit correctly, the OnPropertyChanged method is called ok, but the UI doesn’t update

Is there something extra that needs to be done when setting a property trough reflection? I ‘m guessing the Events aren’t raised properly but i can’t figure out what to do.

Solved there was an extra model inserted before the downloader call, the line should’ve said:

object Owner = Model.GetType().GetProperty("Owner").GetValue(Model, null);               
Model.GetType().GetProperty(_loadingProperty).SetValue(Owner, true, null);
  • 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-27T18:45:18+00:00Added an answer on May 27, 2026 at 6:45 pm

    The following lines

    ((Model as GenericModel).Owner as GenericPageModel).IsLoading = true;  // Works!!
    Model.GetType().GetProperty(_loadingProperty).SetValue(Model, true, null); // Doesn't work
    

    are not equivalent. The first affects the IsLoading property on the Model.Owner object, the second on the Model object itself.

    Note: your ViewModel base class really shouldn’t be called GenericModel as it’s the ViewModel, not the Model.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.