listview doesn't get updated after changing isSelected property

I use an ObservableCollection<customclass> with an isSelected property bound to a listview. The customclass items are added via asyncrhonous communication with a server. I register to an NotifyCollectionChanged event and there under certain conditions set the isSelected property to true. However, this doesn't update my view. Only after selecting another item does the view get updated. Any idea how this is possible?

Also, items that are not visible only get added to the selectedItems list after they have been scrolled into view. Can this be changed?

<ListBox SelectionMode="Multiple" Style="{StaticResource listBoxStyle}" Margin="12,42,12,43" Name="listConfigurations" ItemsSource="{Binding CustomClass.observablecollection1}" VirtualizingStackPanel.IsVirtualizing="False"> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/> </Style> </ListBox.ItemContainerStyle> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Cursor="Hand" Margin="3" Text="{Binding name}"/> </DataTemplate> </ListBox.ItemTemplate>

The CustomClass has one observable list:

public class CustomClass : AbstractClass { public ObservableCollection<AnotherCustomClass> observablecollection1 { get; set; } public CustomClass() : base() { this.observablecollection1 = new ObservableCollection<AnotherCustomClass>(); } public override void http_DownloadStringCompletedEventHandler(object sender, DownloadStringCompletedEventArgs e) { if (e.Error == null) { Collection<AnotherCustomClass> collection = new Collection<AnotherCustomClass>(); //Use JSON parser to put the e.Result into the collection, this works collection = (ObservableCollection<AnotherCustomClass>)parseJSON(e.Result) foreach (AnotherCustomClass collectionObject in collection) { collectionObject.IsSelected = customSettings.Default.savedList.Contains(collectionObject.name); } } } }

Category:.net Time:2010-08-25 Views:0

Related post

  • RemoveAt in Observable Collection, also modifies IsSelected Property in ListView 2009-02-22

    I would try as much explicit as I can. I have two UI objects, this is a TabControl and a ListView, both are binded again two different list of the same objects, both have the IsSelected property binded against the Item.IsSelected as the View Model Co

  • ListView Binding with "IsSelected" Property of ListViewItem 2009-01-27

    I have following class public abstract class AbsTrinityEvent { public event IsSelected OnSelectedEvent; bool _IsSelected; ITrinityEvent _objTrinityEvent; public AbsTrinityEvent(ITrinityEvent objTrinityEvent) { _objTrinityEvent = objTrinityEvent; } pu

  • ListView isn't being updated 2011-12-12

    What/how shall I force view to update itself? My listView is not being updated and only after if I press show/hide button (which shows/hides this view) on my dialog the view is being updated. void No_Files_Match_Regex_Dialog::show_files(bool show) {

  • Wpf DataGrid virtualization issues when binding to DataGridRow.IsSelected property 2011-10-21

    I am having issues with how virtualization works with WPF DataGrid. I am using MVVM and binding all my row viewmodels to the IsSelected property. I need to unselect all rows occasionally, so I do this by updating my underlying row viewmodels to IsSel

  • Binding to the IsSelected property of the parent ListViewItem 2011-10-24

    I'm attempting to bind the Visibility property of a TextBlock that's held within the ItemTemplate for a ListView to the IsSelected property of the TextBlock's parent ListViewItem. With this markup, the TextBlock is always visible. <ListView x:Name

  • Binding the IsSelected property of ListBoxItem to a property on the object from it's source 2009-12-09

    I have a WPF ListBox control and I'm setting its ItemsSource to a collection of item objects. How can I bind the IsSelected property of the ListBoxItem to a Selected property of a corresponding item object without having an instance of the object to

  • Simple C# List: given the primary key, how to find and update a nested object property in a List? 2010-07-26

    Simple IList update question: given the following nested objects, how do you update the deepest nested property given the primary key? public class Recipe { public int RecipeID {get;set;} // PK public string name {get;set;} public IList<RecipeStep

  • IsSelected property of ViewModel bound to ListBox, Only FIRST item selection works? 2010-09-12

    I have a MeetingViewModelList bound to a DataGrid. Each MeetingViewModel has a DocumentViewModelList bound to a ListBox within the DataGrid`s DataGridTemplateColumn. The IsSelected property of the DocumentViewModel is bound to the ListBox`s Item prop

  • How to create IsSelected property for custom itemscontrolItem? 2011-01-07

    I am trying to create a custom ItemsControl by directly inheriting from ItemsControl (WPF/Silverlight, I am using same code base for both). I have created an Item class for it by inheriting from ContentControl. I want to create IsSelected property fo

  • Entity Framework 4 - Updating a single entity property in N-Tier dilemma 2011-04-05

    We have an n-tier app that includes a DB , on top of it EF4 , then WCF services and finally a silverlight 4 client. We are thinking what is the best way to update a single entity property. We have a Customer entity which has about 15 properties. Now,

  • How can i bind a IsSelected Property to a textblock 2011-09-05

    my treeview is populated with textblock items. If a user clicks on a textblock, i want to set a property in my model called "isSelected". But : the textblock have no Property IsSelected. How can i Implement this ? Derive from textblock and add a Prop

  • Search a node in WPF treeview and set IsSelected property 2011-11-30

    I have a treeview with checkboxes in WPF window. I have used togglebuttons for treeviewitems. Now the problem is that, i am searching the node from treeview but i cant set its Isselected property or focus on that node. How to do that? --------------S

  • Adding IsSelected property to EF POCO 2012-01-16

    I have a WCF service that uses EF to pass data to my Silverlight application. I need to have users select multiple items from a combobox bound to an ObservableCollection<SHOP>. I am trying to add an IsSelected property to the POCO on the Silver

  • Can MultiselectList be used in MVVM style(bind its IsSelected property to viewmodel)? 2012-04-10

    I read the example of using MultiselectList in WindowsPhoneGeek part1 part2 When I implementing the SelectAll and UnSelectAll function of the MultiselectList, I find that not all the items in MultiselectList were Select/UnSelect properly if the numbe

  • WPF Listview + GridView - View not Updating 2009-08-06

    I have got a Listview Item with a Gridview Child, bound to a List of Objects. Below the Gridview I have got texboxes to edit the content of the Gridview (bound to the Gridview). I can add new content (which is displayed in the GridView). When i edit

  • Changing data items in ListView and SQLite table update - is it too expensive? 2011-02-05

    I have a ListView containing numbered items with unique IDs. What I want to do is when I change an item's ID from e.g. 85 to 3, I would also want to update all other items to increase all IDs >= 3 by 1: 3->4 4->5 5->6 ... To do that, I wo

  • Android ListView/Adapter - IllegalStateException when updating ArrayList 2011-04-05

    First off, I have looked around the site and could not find a solution to my question, other than "hide the ListView". This is not a viable solution in my case! So, the problem: I have created my own "EndlessAdapter" which allows me to populate the A

  • Listview does not auto update itself 2011-08-21

    each time my activty receives a message (from some TCP listening thread), it does mLstAdpChatScreen.add(line); updateUI(); private void updateUI() { runOnUiThread(new Runnable() { public void run() { mLstAdpChatScreen.notifyDataSetChanged(); mLstAdpC

  • Update ListView when Collection datasource updates 2011-11-29

    I have ListView which I am binding to a Dictionary collection, but new new items are added to the collection, the listview is not updating. How this can be achieved in WPF? --------------Solutions------------- Both sides of WPF binding should support

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.407 (s). 13 q(s)