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

The Archive Base Latest Questions

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

I have CollectionViewSource in which dates grouped by years and months. Dates are displayed

  • 0

I have CollectionViewSource in which dates grouped by years and months. Dates are displayed in TreeView (accurately in RadTreeView).

The target is to change selected date without recreating the view (do not call Refresh method).

To do this I implemented IEditableObject in date view model and changed date so:

var selectedDate = SelectedDate;

var editableCollectionView = Dates.View as IEditableCollectionView;
if (null != editableCollectionView && !editableCollectionView.IsEditingItem)
{
    editableCollectionView.EditItem(selectedDate);
    selectedDate.Date = dt.Date;
    editableCollectionView.CommitEdit();
}

But in this case TreeView lost selection and I need to select “selected item” again that leads refreshing data bounded to selected date.

How can I solve this issue? Perfectly using MVVM way.

UPDATE:

If date is alone in group, changing date causes collapsing item which contains it.

UPDATE 2:

May be I shouldn’t use SelectedDate property and work only with IsSelected and IsExpanded?

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

    Leverage MVVM for Tree View Item.

    Include two writeable properties in your item level class (which serves as the data context to your individual tree view item)

    1. IsExpanded
    2. IsSelected

    Have INotifyPropertyChanged implemented and property changed notification raised in the setter of the above two properties.

    Now at TreeViewLevel have a Style that binds these properties.

     <TreeView.Resources>
        <Style TargetType="{x:Type TreeViewItem}">
            <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
        ....
     </...> 
    

    This way the expansion and selection is maintained on the tree view as long as it is maintained in the tree view item’s data context.

    Now remember that expanded states can be true for multiple items but selection state true is applicable for only one item along the entire tree view.

    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 defined my binding thus: <TreeView ItemsSource={Binding UsersView.View} ItemTemplate={StaticResource MyDataTemplate} /> The CollectionViewSource
I have a TreeView databound to a CollectionViewSource Groups collection. This is so that
In my WPF application I have a CollectionViewSource which is providing a view to
I have a listbox which is bound to a CollectionViewSource (backed by an ObservableCollection).
i have a ListBox with its ItemsSource bound to a CollectionViewSource, which is bound
Sorrry guys, I'm stuck here. I have a few grids, I also have CollectionViewSource
The CollectionViewSource.GetDefaultView() method is not in Silverlight 3. In WPF I have this extension
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I have been building an application, which uses the LoadOperation's Entities to return an
I have a collection of objects stored in a CollectionViewSource and bound to a

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.