.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

CollectionViewSource sort not reflecting automatically after ObservableCollection item property chan

Posted By:      Posted Date: October 14, 2010    Points: 0   Category :WPF

I use a CollectionViewSource to feed the Items of a ListView.  My CollectionViewSource is bound to an ObservableCollection that contains items that implement INotifyPropertyChanged.  Item property changes are being appropriately reflected in the ListView, but I'm surprised to find that the item does not automatically get resorted when its property that the sort is keying off of changes.  It would seem that all the information should be there for the ListView to recognize the need to resort the changed item.  Is there a way to make this happen or another 'lighter' alternative to calling Refresh() on the view?





View Complete Post

More Related Resource Links

Automatically set a property value for a new record in a Dynamic Data application.


I have a SalesOrderItem table, and it has a UnitPrice column in case the salesperson wishes to override the unit price of the Product for that order item.

In an ASP.NET Dynamic Data application, what would be the best way to set that UnitPrice property on a new SalesOrderItem based on the standard UnitPrice for the product? In other words, when the user clicks New on the 'Items' screen for a sales order, the UnitPrice field should already be filled in with the normal unit price for the product.

This was originally asked by myself on StackOverflow at: http://stackoverflow.com/questions/3538234/automatically-set-a-property-value-for-a-new-record-in-a-dynamic-data-application

CollectionViewSource/BindingListCollectionView to ObservableCollection/ListCollection

i have watched the tutorial How Do I: Build a WPF Data Entry Form Using Entity Framework? i am confused why the need to change a CollectionViewSource/BindingListCollectionView to ObservableCollection/ListCollection start code:   var viewSource = (CollectionViewSource) this .Resources["customersViewSource" ]; var result = from cust in database.Customers select cust; viewSource.Source = result; view = (BindingListCollectionView)viewSource.View; to something like (end code )   var customerSource = ((CollectionViewSource)(this.FindResource("CustomerSource"))); var query = from c in db.Customers where c.City == "Seattle" select c; this.CustomerData = new CustomerCollection(query, db); customerSource.Source = this.CustomerData; this.View = ((ListCollectionView)(customerSource.View));   also in CustomerCollection protected override void InsertItem(int index, Customer cust) { this.context.AddToCustomers(cust); base.InsertItem(index, cust); } protected override void RemoveItem(int index) { this.context.DeleteObject(this[index]); base.RemoveItem(index); } then in here, why the need to insert/delete the customer from the context then from the base collection view? then why dont i need the same for update?  

Databound DropDownList Item Value Property Localization

I am using a databound DropDownList in which the item's Text field is set to a text representation of an identifier value of type int.  I am filling the Value field of the ListItem with the int value.  All of this is being done through the setup of the DataTextField and DataValueField settings of the DropDownList control. However, since both the item Value and Text fields are strings, obviously a conversion must be performed at the time of binding to convert the non-string value to a string value.  I am making the assumption that the ToString() method for the value is invoked in order to convert the int value into a string so that it can be stored in the Value property of the ListItem. Once selections are made, I read the Value property of the SelectedItem to perform an action.  It occurred to me that converting back to the original data type might present a problem if the wrong culture information is used to perform the conversion. My question is, in the case of non-string values being automatically converted for a databound DropDownList, what culture is used to perform that conversion?  My initial guess would be the CurrentCulture, simply because no object is required to supply a ToString() overload which allows the specification of an IFormatProvider object.  However, if the System.Convert object is used to perform the conversion

Workflow - automatically create discussion item using title field of of custom list item as its subj

Anyone any ideas as to how I can configure SharePoint to create a discussion item using the title of a list item. e.g. user creates list item on a custom list - SP automatically creates a Discussion thread for this list item in the discussions list. I'm guessing this can't be down OOTB . would I be looking at SPD or a coded solution ? regards, Counie

How automatically update a calculated property in wpf

Hi, For example: I have a class MediaList with a list of mediaitems. (Movie, Serie, Season, Episode). All these classes have a property FileSize. So we get this structure: Movie has a property FileSize. Serie has a property FileSize and a property Seasons. Seasons has a property FileSize and a property Episodes. Episode has a property FileSize If have a calculated property FileSize on MediaList that i want to show. If one episode or movie is deleted, the parents fileSize needs to be updated until MediaList.FileSize is updated. What is the best practices to handle this kind of properties? Thx   

Automatically select item with keyboard navigation in a combobox


Hi there,

in a WinForms ComboBox the selected item automatically changes, when I navigate through the combobox items with keyboard.

However, in the WPF ComboBox (IsEditable = false), the item in the list is highlighted but not automatically selected. Is there a way to change this behaviour?




How to make ObservableCollection setter trigger when property value changes?


My class has a property ObservableCollection<MyType>. When any value of MyType changes, I want the setter for my property to be hit. It seems the setter is only hit when the CollectionChanged event is thrown, but in this case the Collection isn't changing, just a value of one of the properties in my Collection. 


Any pointers?

InnerException: There was an error reflecting property 'xxxxxx'


I am working on a project which use VB.NET (.NET 2) to call a WCF .NET 3.5 WS via proxy class (in basicHTTPbinding).  Before I can call any web method in the proxy class, I need to customise soap header by add two soap header attributes: __UserName, __SessionID into the soap header (as part of requirements).

To approach this problem I have created a partial class inside the proxy class to inherit the soapHeader class:

<System.SerializableAttribute(), _
        System.ComponentModel.DesignerCategoryAttribute("code"), _
         System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://xyz/"), _
         System.Xml.Serialization.XmlRootAttribute([Namespace]:="http://xyz/", IsNullable:=False)> _
    Partial Public Class mySoapHeader
        Inherits System.Web.Services.Protocols.SoapHeader

        Private __UserNameField As System.Xml.XmlAttribute
        Private __SessionIDField As System.Xml.XmlAttribute


BCS external item picker - automatically fill up



We use CRM and Sharepoint and would like to export all the documents from CRM and file shares to Sharepoint. 
This already works and I can add documents in to the library with custom properties.

In my sharepoint library I'm using an external data field to look for my contact ID's in CRM to link with the corresponding document.

Question now is: how can I programmatically fill up this external item picker with the correct contactID when I'm moving my documents all at once?

SPDocumentLibrary doclib = (SPDocumentLibrary

<%= Html.DisplayFor(item=>item.Property) %> extremely slow


I am passing a List with Model objects to my view and display them using

<%= Html.DisplayFor(i=>item.Property) %>

.and DisplayTemplates to show the properties. However, it takes second to render the page? How come it is so extremely slow? Am doing something wrong?

Add Related/Child List Item? - How to automatically set the relationship?




I've got a parent/child relationship between two lists.  I have the parent form set to automatically include child records.

The problem I'm having is that when I "Add new item," it is not associating the new record with the parent record automatically.

How do I have it automatically set the key field?

Thanks in advance for any suggestions,




calendar item automatically delete upon request rejected.



i got an issue where i've created a workflow and attached it to a calendar so the workflow will starts when new item is created. if the PIC reject the item can MOSS delete the item from calendar once the PIC reject it?



Override ComboBox Text property after selected an item


Hi All

I tried many ways , but have non can successfully alter the combo box Text after selected an item from drop down, and I want to make sure this is just not possible.

This is what I need, if after I selected an item - "1 apple" from the drop down, i want the combo box shows text, "1". I tried write code in different eventhandlers, overrider Text property, clear items . non of those way can achieve this.

 public class AccountComboBox : ComboBox
    public override string Text
        return base.Text;
        if (this.SelectedItem != null)

          base.Text = SelectedItem.ToString().Remove(this.SelectedItem.ToString().IndexOf(" "));

workflow runs when item changed even though only 'Automatically start ... is changed' is unselecte


We have an SPDesigner workflow on a form library in SP2007 SP2 (& some CU updates).

Its 'Automatically start this workflow whenever an item is changed' is unchecked.  The other 2 options '...new item is created.' and '... manually started...' are checked.

We add an item into the list.  The workflow starts.  We see the 'Approval Workflow Started' in the workflow history.  And approver then approves the item, and in the workflow history, we then see the 'Approval Workflow Started' again.  It's as if the workflow has restarted. 

This errant behavior seems to have started when we added an if condition in second step of our workflow:

If Checked Out to is not empty

 Log xxxyyy to workflow history

 then Wait for Checked Out To to be empty 

Is it a known bug in SP2007?


A little more info on this:

We have a workflow step that :

Store https://url/blah in Variable:Blah URL

  then Check out item in OurFormLibraryName

  then Set Approval Status to Awaiting Approvers Approval

  then Set ... another field value ...

  then Check in item OurFor

How to sort GridView?

In this article I will discuss how to sort columns in grid and more. At the end it will help answer some very frequently asked questions like following

WPF / Silverlight tutorial: Visibility property and binding

Visibility property is a very powerful and yet often overlooked property available in both WPF and Silverlight. It enables you to set Visibility of certain UIElement objects to different states like: Visible, Collapsed and Hidden (not supported by Silverlight). This tutorial shows you how to use it and how to bind to Visibility property

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend