Good Evening All,
I am new to wpf and I am in need of some desperate assistance. I can honestly say I've put more hours searching than I've slept lately.
So far I read in an xml file to an observable collection. Then create a CollectionViewSource in xaml referencing this observable collection. Then databind a datagrid to the properties of the collectionviewsource. All this works correctly.
Now I want to add some customization of the display. Say for example I have 3 names in my CVS.
1.GOLD
2.GOLD
3.SILVER
What I want is just to show two items in my grid... GOLD and SILVER. Just 1 time each. Basically the same as saying SELECT DISTINCT in SQL.
So far I am using multibinding/multiconverted to bring in the values... but I am stuck here.
In fact I don't even know if I am going about it the correct way.
Can someone please point me in the right direction? How can I display only 1 occurrence of the names in my list?
Here is my xaml...
Window.Resources>
<local:DataBindingClass x:Key="formatter"/>
<local:MyDataSource x:Key="MyData"/>
<CollectionViewSource x:Key="ViewSource" Source="{Binding Source={StaticResource ResourceKey=MyData}, Path=TradesClass}"/>
</Window.Resources
> <window.resources>
<local:databindingclass x:key="formatter" xmlns:x="#unknown" xmlns:local="#unknown" />
<local:mydatasource x:key="MyData" xmlns:x="#unknown" xmlns:local="#unknown" />
<collectionviewsource x:key="ViewSource" source="{Binding Source={StaticResource ResourceKey=MyData}, Path=TradesClass}" xmlns:x="#unknown" />
</window.resources>
<pre>
<DataGrid
x:Name="DataGridBreakdown"
Margin="10"
MaxHeight="300"
VerticalAlignment="Top"
CanUserAddRows="False"
AutoGenerateColumns="False"
HorizontalContentAlignment="Stretch"
ItemsSource="{Binding Source={StaticResource ViewSource}}"
>
<DataGrid.Resources>
<local:BreakdownGridValueConverter x:Key="myConverter"/>
</DataGrid.Resources>
<!--
<DataGrid.Columns>
<DataGridTextColumn Header="Market">
<DataGridTextColumn.Binding>
<MultiBinding Converter="{StaticResource ResourceKey=myConverter}">
<!--
<Binding Path="tMarketName"/>
<Binding Source="{StaticResource ResourceKey=MyData}"/>
</MultiBinding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
<DataGridTextColumn Header="Delta" Binding="{Binding tDeltaLive}"/>
<DataGridTextColumn Header="Prev Pos." Binding="{Binding Path=tDeltaLive}" />
</DataGrid.Columns>
</DataGrid>