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

  • Home
  • SEARCH
  • 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 4086406
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:43:21+00:00 2026-05-20T18:43:21+00:00

I am working on creating a Windows Phone app that will play a series

  • 0

I am working on creating a Windows Phone app that will play a series of sound clips selected from a list. I am using the MVVM (Model View View-Model) Design pattern and have designed a model for my data, along with a view model for my page. Here is what the XAML for the ListBox looks like:

<ListBox x:Name="MediaListBox" Margin="0,0,-12,0" ItemsSource="{Binding Media}" SelectionChanged="MediaListBox_SelectionChanged" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">

                <ListBox.ItemTemplate >
                    <DataTemplate>
                        <StackPanel Margin="0,0,0,17" Width="432" Orientation="Horizontal">
                            <Image Source="../Media/Images/play.png" />
                            <StackPanel >
                                <TextBlock Text="{Binding Title}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                                <TextBlock Text="{Binding ShortDescription}" TextWrapping="Wrap" Margin="12,-6,12,0" Visibility="{Binding ShortDescriptionVisibility}" Style="{StaticResource PhoneTextSubtleStyle}"/>
                                <TextBlock Text="{Binding LongDescription}" TextWrapping="Wrap" Visibility="{Binding LongDescriptionVisibility}" />
                                <StackPanel>
                                    <Slider HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Visibility="{Binding LongDescriptionVisibility}" ValueChanged="Slider_ValueChanged" LargeChange="0.25" SmallChange="0.05" />
                                </StackPanel>
                            </StackPanel>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

My question is this: I want to be able to expand and collapse part of the items in the ListBox. As you can see, I have a binding for the visibility. That binding is coming from the MediaModel. However, when I change this property in the ObservableCollection, the page is not updated to reflect this.

The ViewModel for this page looks like this:

public class ListenPageViewModel : INotifyPropertyChanged
{
    public ListenPageViewModel()
    {
        this.Media = new ObservableCollection<MediaModel>;

    }

    /// <summary>
    /// A collection for MediaModel objects.
    /// </summary>
    public ObservableCollection<MediaModel> Media { get; private set; }

    public bool IsDataLoaded { get; private set; }

    /// <summary>
    /// Creates and adds the media to their respective collections.
    /// </summary>
    public void LoadData()
    {
        this.Media.Clear();
        this.Media.Add(new MediaModel()
        {
            Title = "Media 1",
            ShortDescription = "Short here.",
            LongDescription = "Long here.",
            MediaSource = "/Media/test.mp3",
            LongDescriptionVisibility = Visibility.Collapsed,
            ShortDescriptionVisibility = Visibility.Visible
        });

        this.Media.Add(new MediaModel()
        {
            Title = "Media 2",
            ShortDescription = "Short here.",
            LongDescription = "Long here.",
            MediaSource = "/Media/test2.mp3",
            LongDescriptionVisibility = Visibility.Collapsed,
            ShortDescriptionVisibility = Visibility.Visible
        });

        this.IsDataLoaded = true;
    }

    public event PropertyChangedEventHandler PropertyChanged;
    private void NotifyPropertyChanged(String propertyName)
    {
        PropertyChangedEventHandler handler = PropertyChanged;
        if (null != handler)
        {
            handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

The bindings work correctly and I am seeing the data displayed; however, when I change the properties, the list does not update. I believe that this may be because when I change things inside the observable collection, the property changed event is not firing.

What can I do to remedy this? I have poked around for some info on this, but many of the tutorials don’t cover this kind of behavior. Any help would be greatly appreciated!

Thanks

Edit: As requested, I have added the MediaModel code:

    public class MediaModel : INotifyPropertyChanged
{
    public string Title { get; set; }
    public string ShortDescription { get; set; }
    public string LongDescription { get; set; }
    public string MediaSource { get; set; }
    public Visibility LongDescriptionVisibility { get; set; }
    public Visibility ShortDescriptionVisibility { get; set; }

    public MediaModel()
    {
    }

    public MediaModel(string Title, string ShortDescription, string LongDescription, string MediaSource, Visibility LongDescriptionVisibility, Visibility ShortDescriptionVisibility)
    {
        this.Title = Title;
        this.ShortDescription = ShortDescription;
        this.LongDescription = LongDescription;
        this.MediaSource = MediaSource;
        this.LongDescriptionVisibility = LongDescriptionVisibility;
        this.ShortDescriptionVisibility = ShortDescriptionVisibility;
    }
    public event PropertyChangedEventHandler PropertyChanged;
    private void NotifyPropertyChanged(String propertyName)
    {
        PropertyChangedEventHandler handler = PropertyChanged;
        if (null != handler)
        {
            handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

Originally, I did not have this class implement the INotifyPropertyChanged. I did this to see if it would solve the problem. I was hoping this could just be a data object.

  • 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-20T18:43:21+00:00Added an answer on May 20, 2026 at 6:43 pm

    Try changing your long description visibility property to this to see if that fixes it

    private Visibility _longDescriptionVisibility;
    public Visibility LongDescriptionVisibility
    {
        get { return _longDescriptionVisibility; }
        set
        {
            _longDescriptionVisibility = value;
            NotifyPropertyChanged("LongDescriptionVisibility");
        }
    }       
    

    If it does make the same change to the short description property.

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

Sidebar

Related Questions

I am working on creating a web app that will query event logs on
I'm working on creating a domain layer in Zend Framework that is separate from
I am creating Windows service class in Python that will eventually display a Window
I'm working on a project that involves creating a spline from a defined set
I'm currently working on creating a new C# project that needs to interact with
I am working on creating a daemon in Ruby using the daemons gem. I
Working inside the context of an ASP.NET application I am creating a page that
I'm creating an WPF app, so I'm mostly working with the ImageSource class for
I am working on creating a windows mobile application and I have a quick
I've been working on creating a Windows Desktop Gadget. I can create HTML elements

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.