Quantcast
Viewing all articles
Browse latest Browse all 9

Problem with grouping in listView

Hi

I have created class "Devices" and I want to group it in listview and use Gridviewcolumns. All devices are in ObservableCollection object MyDevices. Everything works fine until I change Devices class to inheritate after ListViewItem. After that listview show Content of listviewitem and DisplayMemberBinding="{Binding Path=ID}"  is useles. I see blank rows. When I change "Devices" class to inheritate after TreeViewItem content in shown but I can`t use IsSelected property.

 

I have attached XAML code. Please help.

 

<ObjectDataProvider x:Key="devices" ObjectType="{x:Type ds:MyDevices}"/>

<CollectionViewSource x:Key='src' Source="{Binding Source={StaticResourcedevices}}">

<CollectionViewSource.GroupDescriptions>

<PropertyGroupDescription PropertyName="Description" />

</CollectionViewSource.GroupDescriptions>

</CollectionViewSource>

<ListView Margin="3,0,5,0" Grid.Row="1" Grid.RowSpan="2" Name="lv" ItemsSource="{Binding Source={StaticResource src}}">

<ListView.GroupStyle>

<GroupStyle>

<GroupStyle.ContainerStyle>

<Style TargetType="{x:Type GroupItem}">

<Setter Property="Margin" Value="0,0,0,5"/>

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="{x:Type GroupItem}">

<Expander IsExpanded="True" BorderBrush="#FFA4B97F" BorderThickness="0,0,0,1">

<Expander.Header>

<GridMouseDown="DockPanel_MouseDown">

<Grid.RowDefinitions>

<RowDefinition/>

<RowDefinition/>

</Grid.RowDefinitions>

<DockPanel Margin="10,0,0,0">

<TextBlock Name="nazwa" FontWeight="Bold" Text="{Binding Path=Name}" />

</DockPanel>

<DockPanel Grid.Row="1" Margin="10,0,0,0">

<TextBlock FontWeight="Bold" Text="{Binding Path=ItemCount}"/>

</DockPanel>

</Grid>

</Expander.Header>

<Expander.Content>

<ItemsPresenter />

</Expander.Content>

</Expander>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

</GroupStyle.ContainerStyle>

</GroupStyle>

</ListView.GroupStyle>

<ListView.View>

<GridView>

<GridViewColumn Header="ID" Width="50" DisplayMemberBinding="{Binding Path=ID}"></GridViewColumn>

<GridViewColumn Header="Adress" Width="150" DisplayMemberBinding="{Binding Path=Adress}"></GridViewColumn>

</GridView>

</ListView.View>

</ListView>

Viewing all articles
Browse latest Browse all 9

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>