Note that there are some explanatory texts on larger screens.

plurals
  1. POConversion from ReadOnlyObservableCollection to List<MyClass>
    primarykey
    data
    text
    <p>I have a datagrid with grouping and I am trying to style the template to add in some summary about the group. </p> <p><strong>IN XAML DataGrid.RowGroupHeaderStyle</strong></p> <pre><code> &lt;Grid Grid.Column="3" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="0,1,0,1" &gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="200"/&gt; &lt;ColumnDefinition Width="*"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;TextBlock Grid.Column="0" Text="{Binding Name}" Margin="4,0,0,0" /&gt; &lt;TextBlock Grid.Column="1" Text="{Binding Items, Converter="{StaticResource summaryConverter}"}" /&gt; &lt;/Grid&gt; </code></pre> <p><strong>Binding of data grid items source</strong> </p> <pre><code> PagedCollectionView collection = new PagedCollectionView(e.Result.ToList&lt;MyClass&gt;()); collection.GroupDescriptions.Add(new PropertyGroupDescription("Name")); dataGrid.ItemsSource = collection; </code></pre> <p><strong>MyClass</strong></p> <pre><code> class MyClass { public string Name; public double Value; } </code></pre> <p>I have created a converter to grab the Items of the same group but I am facing problem in converting the object into <code>List&lt;MyClass&gt;()</code>. I receive this error</p> <blockquote> <p>Unable to cast object of type 'System.Collections.ObjectModel.ReadOnlyObservableCollection<code>1[System.Object]' to type 'System.Collections.Generic.List</code>1[MyClass]'. `</p> </blockquote> <p><strong>In Converter.cs</strong></p> <pre><code> public object Convert(object values, Type targetType, object param, CultureInfo culture) { var source = (List&lt;MyClass&gt;)values; } </code></pre> <p>Does anyone know how should I do the conversion??</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload