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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:16:29+00:00 2026-05-25T20:16:29+00:00

My application has a couple of ObservableCollections, one which is nested within an element

  • 0

My application has a couple of ObservableCollections, one which is nested within an element of the other. Each contain a number of fields e.g.

ObservableCollectionA (called Listings)

  • Title
  • Description
  • Address
  • Images As MediaItems

ObservableCollectionB (called MediaItems)

  • ImageName
  • Src
  • DisplayTime

Currently I have been accessing ObservableCollections as follows:

Listings(0).MediaItems(0).ImageName

My application has the main Window display the items from Listings and a UserControl which contains a ListBox which displays the items from MediaItems.

Currently my Window is bound to Listings using code in the New method:

Dim AppLocal As Program = Application.CurrentItem
AppLocal.CurrentItem = 0
Me.DataContext = Listings.Item(AppLocal.CurrentItem)

For the Listings ObservableCollection, the UserControl has a XAML DataContext which references a local method which pulls the records from the nested MediaItems ObservableCollection.

<UserControl.DataContext>
    <ObjectDataProvider ObjectType="{x:Type local:ThumbImageLoader}" MethodName="LoadImagesv2" IsAsynchronous="True"  />
</UserControl.DataContext>
<Grid x:Name="ThumbListBoxGrid">
    <ListBox x:Name="ThumbListBox" ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True" />
</Grid>

The method is here:

Public NotInheritable Class ThumbImageLoader
Public Shared Function LoadImagesv2() As List(Of MediaItems)

    Dim AppLocal As Program = Application.Current

    Dim ThumbImages As New List(Of MediaItems)

    ThumbImages = Listings(AppLocal.CurrentItem).MediaItems

    Return ThumbImages
End Function
End Class

Whilst developing the UI layout I have just been binding the first item (0 index). I now want to be able to set AppLocal.CurrentItem from anywhere in the application so the Window and the ListBox are updated.

Ideally I would like it so when the global property index changes, the UI is updated.

How do I do this?

Is there a better way to go about it?

Ben

  • 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-25T20:16:30+00:00Added an answer on May 25, 2026 at 8:16 pm

    Ok, I discovered the joy of CollectionView. Offered exactly what I was after and was excrutiatingly easy to implement. I was blown away at not only how easy it was to implement, but I managed to cut out more lines of code than I used to implement it.

    I implemented a public CollectionViewSource

    Public ListingDataView As CollectionViewSource
    

    In my main Window, I implemeted it as follows:

    <CollectionViewSource x:Key="ListingDataView" />
    

    and bound my top-level Grid to it:

    <Grid DataContext="{Binding Source={StaticResource ListingDataView}}">
    

    In my Application Startup I set the CollectionView Source

    AppLocal.ListingDataView = CType(Application.Current.MainWindow.Resources("ListingDataView"), CollectionViewSource)
    AppLocal.ListingDataView.Source = Listings
    

    The next part which impressed me the most was implementing it for my User Control. I remembered the UserControl is inheriting from the main window so it has access to the CollectionView already, so I ditched the separate Class and Method binding in favour for this:

    <ListBox ItemsSource="{Binding Path=MediaItems}" VerticalAlignment="Top" IsSynchronizedWithCurrentItem="True" />
    

    Now whene I want to set the Current List Index, I simply call this:

    AppLocal.ListingDataView.View.MoveCurrentToPosition(AppLocal.CurrentProperty)
    

    A few milliseconds later, the UI updates automatically.

    Done!!

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

Sidebar

Related Questions

I have an application which has a couple of UITextField present to allow my
Our application has a couple of shell scripts that are called from web-based Oracle
I have an application that has several stores , and each store has several
My typical application has a couple of textboxes, checkbuttons, radiobuttons, and so. I always
I have assisted with an application that has a couple of thousand deployments. This
My MFC application has a CView and a couple of floating non-modal dialogs. I
Scenario: I have an application that has a config table which stores the config
My application has couple of backbone models and collection. I want to place an
My application currently has 2 forms. It creates a sub form, Form2, which ends
I am looking to build an application that has a couple different modes. The

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.