<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>WPF DataGrid: Tri-state Sorting sample</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx</link><description>Here is a short sample on how to create a tri-state sorting experience with the WPF DataGrid . In the current design, when clicking on a column header it will toggle sorting of the column starting from ascending to descending. Unfortunately you cannot</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>discount furniture &amp;raquo; WPF DataGrid: Tri-state Sorting sample</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx#8905637</link><pubDate>Fri, 29 Aug 2008 19:19:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8905637</guid><dc:creator>discount furniture &amp;raquo; WPF DataGrid: Tri-state Sorting sample</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://informationsfunnywallpaper.cn/?p=2939"&gt;http://informationsfunnywallpaper.cn/?p=2939&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>WPF DataGrid: Stock and Template Columns</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx#8905695</link><pubDate>Fri, 29 Aug 2008 19:32:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8905695</guid><dc:creator>Vincent Sibal's Blog</dc:creator><description>&lt;p&gt;Overview The DataGrid uses a set of DataGridColumns to describe how to display its data just like a GridView&lt;/p&gt;
</description></item><item><title>WPF DataGrid: Working with DataGridComboBoxColumn</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx#8905707</link><pubDate>Fri, 29 Aug 2008 19:35:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8905707</guid><dc:creator>Vincent Sibal's Blog</dc:creator><description>&lt;p&gt;If you haven’t already, you can download the binaries and source for the DataGrid here . DataGridComboBoxColumn&lt;/p&gt;
</description></item><item><title>re: WPF DataGrid: Tri-state Sorting sample</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx#8919694</link><pubDate>Tue, 02 Sep 2008 12:59:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8919694</guid><dc:creator>_gdc</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I need to use the DataGrid with a class that implements IEnumerable&amp;lt;&amp;gt;, &lt;/p&gt;
&lt;p&gt;I don't want to subclass ObservableCollection&amp;lt;&amp;gt;, &lt;/p&gt;
&lt;p&gt;but I have problems doing this.&lt;/p&gt;
&lt;p&gt;Using your example, I change your class:&lt;/p&gt;
&lt;p&gt;public class People : ObservableCollection&amp;lt;Person&amp;gt;&lt;/p&gt;
&lt;p&gt;with this new (where I use _peopleList to keep the data):&lt;/p&gt;
&lt;p&gt;public class People : IEnumerable&amp;lt;Person&amp;gt;&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp;private List&amp;lt;Person&amp;gt; _peopleList;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;private Random random = new Random();&lt;/p&gt;
&lt;p&gt; &amp;nbsp;public People()&lt;/p&gt;
&lt;p&gt; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;CreateGenericPersonData(1);&lt;/p&gt;
&lt;p&gt; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp;public People(int multiplier)&lt;/p&gt;
&lt;p&gt; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;CreateGenericPersonData(multiplier);&lt;/p&gt;
&lt;p&gt; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp;private void CreateGenericPersonData(int multiplier)&lt;/p&gt;
&lt;p&gt; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;_peopleList = new List&amp;lt;Person&amp;gt;();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;if (multiplier &amp;gt; 0)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;for (int i = 0; i &amp;lt; multiplier; i++)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_peopleList.Add(new Person(&amp;quot;George&amp;quot;, &amp;quot;Washington&amp;quot;, GenerateRandomDate()));&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_peopleList.Add(new Person(&amp;quot;John&amp;quot;, &amp;quot;Adams&amp;quot;, GenerateRandomDate()));&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_peopleList.Add(new Person(&amp;quot;Thomas&amp;quot;, &amp;quot;Jefferson&amp;quot;, GenerateRandomDate()));&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//...&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_peopleList.Add(new Person(&amp;quot;George&amp;quot;, &amp;quot;W.&amp;quot;, &amp;quot;Bush&amp;quot;, GenerateRandomDate()));&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp;private DateTime GenerateRandomDate()&lt;/p&gt;
&lt;p&gt; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;int randInt = random.Next();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;return new DateTime(Convert.ToInt64(randInt));&lt;/p&gt;
&lt;p&gt; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp;#region IEnumerable&amp;lt;Person&amp;gt; Members&lt;/p&gt;
&lt;p&gt; &amp;nbsp;public IEnumerator&amp;lt;Person&amp;gt; GetEnumerator()&lt;/p&gt;
&lt;p&gt; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;return _peopleList.GetEnumerator();&lt;/p&gt;
&lt;p&gt; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp;#endregion&lt;/p&gt;
&lt;p&gt; &amp;nbsp;#region IEnumerable Members&lt;/p&gt;
&lt;p&gt; &amp;nbsp;System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()&lt;/p&gt;
&lt;p&gt; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;return _peopleList.GetEnumerator();&lt;/p&gt;
&lt;p&gt; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp;#endregion&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;If I try this, I receive the exception:&lt;/p&gt;
&lt;p&gt;Cannot create instance of 'DataGridBasicSample_Demo' defined in assembly &amp;nbsp;...&lt;/p&gt;
&lt;p&gt;Where am I wrong?&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;</description></item><item><title>re: WPF DataGrid: Tri-state Sorting sample</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx#8920020</link><pubDate>Tue, 02 Sep 2008 16:56:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8920020</guid><dc:creator>vinsibal</dc:creator><description>&lt;p&gt;_gdc,&lt;/p&gt;
&lt;p&gt;In my example I am getting the view from the ItemsSource and expect a ListCollectionView. &amp;nbsp;Since you have changed it to IEnumerable&amp;lt;T&amp;gt; it is no longer a ListCollectionView. &amp;nbsp;In the constructor of my sample, try removing the lines related to getting the CollectionViewSource. &amp;nbsp;It should work after that.&lt;/p&gt;
&lt;p&gt;-Vince&lt;/p&gt;
</description></item><item><title>re: WPF DataGrid: Tri-state Sorting sample</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx#8932958</link><pubDate>Mon, 08 Sep 2008 14:51:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8932958</guid><dc:creator>Karl</dc:creator><description>&lt;p&gt;Started playing with the Datagrid in a WPF app runing on a desktop. &lt;/p&gt;
&lt;p&gt;I have notice that when I drag the scroll button on some machines, there is a pretty chunky lag. The content redraw updates in a unpleasant, laggy way. &lt;/p&gt;
&lt;p&gt;There were only 500 items in the grid... &lt;/p&gt;</description></item><item><title>re: WPF DataGrid: Tri-state Sorting sample</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx#8933058</link><pubDate>Mon, 08 Sep 2008 15:28:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8933058</guid><dc:creator>vinsibal</dc:creator><description>&lt;p&gt;Karl,&lt;/p&gt;
&lt;p&gt;Would you mind posting the specs for the machine that you find that it is lagging.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Vince&lt;/p&gt;
</description></item><item><title>re: WPF DataGrid: Tri-state Sorting sample</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx#8933062</link><pubDate>Mon, 08 Sep 2008 15:29:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8933062</guid><dc:creator>Karl </dc:creator><description>&lt;p&gt;Opps never mind. Scrolling works fine. &lt;/p&gt;
&lt;p&gt;The issue is that if I set my ItemSource to an custom &lt;/p&gt;
&lt;p&gt;ObservableCollection&amp;lt;T&amp;gt;&lt;/p&gt;
&lt;p&gt;T must define a public string property named &amp;quot;Id&amp;quot; or the binding will throw a bad path and silently swallow the exception on all the rows.&lt;/p&gt;
&lt;p&gt;Which absolutely kills the performance of scroll.... &lt;/p&gt;
&lt;p&gt;You get this in the output window of the debugger. &lt;/p&gt;
&lt;p&gt;System.Windows.Data Error: 39 : &lt;/p&gt;
&lt;p&gt;BindingExpression path error: 'Id' property not found on 'object' ''RowProxy' (HashCode=11295760)'. &lt;/p&gt;
&lt;p&gt;BindingExpression:Path=Id; DataItem='RowProxy' (HashCode=11295760); &lt;/p&gt;
&lt;p&gt;target element is 'DataGridRow' (Name=''); &lt;/p&gt;
&lt;p&gt;target property is 'Header' (type 'Object') &lt;/p&gt;</description></item><item><title>re: WPF DataGrid: Tri-state Sorting sample</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx#8953608</link><pubDate>Tue, 16 Sep 2008 10:36:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8953608</guid><dc:creator>RobertT</dc:creator><description>&lt;p&gt;Hi Vincent!&lt;/p&gt;
&lt;p&gt;Will you be so kind and help me with a following scenario? =)&lt;/p&gt;
&lt;p&gt;Imagine I have a DataGrid bound with ObservableCollection. I want to prevent user from editing existing rows and enable only to add new rows and edit'em right in a place or delete new or existing rows. How can I achieve such a scenario?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;RobertT&lt;/p&gt;</description></item><item><title>re: WPF DataGrid: Tri-state Sorting sample</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx#8953865</link><pubDate>Tue, 16 Sep 2008 16:07:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8953865</guid><dc:creator>vinsibal</dc:creator><description>&lt;p&gt;RobertT,&lt;/p&gt;
&lt;p&gt;One possible solution is to listen to the DataGrid.BeginningEdit event and cancel the BeginEdit if the row they are trying to edit is an existing row. &amp;nbsp;Deleting is a separate operation so it will work as normal with this solution.&lt;/p&gt;
</description></item><item><title>.NET 3.5 SP1 and WPF DataGrid CTP are out now!</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx#8954014</link><pubDate>Tue, 16 Sep 2008 18:14:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8954014</guid><dc:creator>Vincent Sibal's Blog</dc:creator><description>&lt;p&gt;As you might have heard, .NET Framework 3.5 SP1 and Visual Studio 2008 SP1 are out today! There are a&lt;/p&gt;
</description></item><item><title>WPF DataGrid - Clipboard Paste Sample</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx#8958870</link><pubDate>Fri, 19 Sep 2008 18:07:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8958870</guid><dc:creator>Vincent Sibal's Blog</dc:creator><description>&lt;p&gt;In the v1 release (and CTP) of the WPF DataGrid there will be support for Clipboard.Copy but no support&lt;/p&gt;
</description></item><item><title>re: WPF DataGrid: Tri-state Sorting sample</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx#9174977</link><pubDate>Thu, 04 Dec 2008 15:31:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9174977</guid><dc:creator>Priya</dc:creator><description>&lt;p&gt;Hi, can v populate DataGrid dynamically. If yes, can u post a sample on the same using DataGridTextColumn() and DataGridRow() (similar to how we add in DataTable) Or is there other way of doing it cos am stuck with it. &lt;/p&gt;
&lt;p&gt;Thanks in Advance.&lt;/p&gt;</description></item><item><title>re: WPF DataGrid: Tri-state Sorting sample</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx#9237175</link><pubDate>Thu, 18 Dec 2008 22:51:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9237175</guid><dc:creator>vinsibal</dc:creator><description>&lt;p&gt;Priya,&lt;/p&gt;
&lt;p&gt;DataGrid can be populated dynamically, but not isn the same way as the DataTable. &amp;nbsp;The DataGrid is bound to an ItemsSource so as items are added and removed the DataGrid will update as necessary. &amp;nbsp;Could you expand on your scenario a bit and hopefully I can provide further assistance.&lt;/p&gt;
</description></item><item><title>re: WPF DataGrid: Tri-state Sorting sample</title><link>http://blogs.msdn.com/vinsibal/archive/2008/08/29/wpf-datagrid-tri-state-sorting-sample.aspx#9921259</link><pubDate>Thu, 12 Nov 2009 09:37:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9921259</guid><dc:creator>Bharti</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt; &amp;nbsp;I am using WPF toolokit's data grid, and inthat grid I have a column for checkbox which I add as below:&lt;/p&gt;
&lt;p&gt;&amp;lt;toolkit:DataGridTemplateColumn &amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;toolkit:DataGridTemplateColumn.CellTemplate&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;DataTemplate&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;CheckBox Click=&amp;quot;OnUsedClicked&amp;quot; &amp;nbsp;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IsChecked=&amp;quot;{Binding Path=Used}&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/DataTemplate&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/toolkit:DataGridTemplateColumn.CellTemplate&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/toolkit:DataGridTemplateColumn&amp;gt;&lt;/p&gt;
&lt;p&gt;I would like to sort on all columns of my grid, so to the grid defination I added&lt;/p&gt;
&lt;p&gt;CanUserSortColumns=&amp;quot;True&amp;quot; &amp;nbsp;to my grid.&lt;/p&gt;
&lt;p&gt;On doing this the rest of the columns get sorted but not the checkbox column.By checkbox column sorting I mean that all checked boxes(rows) to be together and all unchecked boxes(rows) to be together. I do understand there might be multiple checked so what basis needs to be used, I have a time column , I can use that along with it. &lt;/p&gt;
&lt;p&gt;i.e sorting on Checkbox + Time&lt;/p&gt;
&lt;p&gt;this would lead to all say unchecked together , based on time as the second parameter.&lt;/p&gt;
&lt;p&gt;I am not sure if this is possible, if yes how?&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Barti&lt;/p&gt;
&lt;p&gt;I would like that &lt;/p&gt;</description></item></channel></rss>