Create a ListView control that implements a GridView view mode, displays content in groups. : ListView « Windows Presentation Foundation « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Windows Presentation Foundation » ListViewScreenshots 
Create a ListView control that implements a GridView view mode, displays content in groups.
Create a ListView control that implements a GridView view mode, displays content in groups.
   

<Window xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
        xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
    <Window.Resources>
        <XmlDataProvider x:Key="MyData" XPath="/Info">
            <x:XData>
                <Info xmlns="">
                    <Item ID="1" Name="Book 1" Price="$2.05" Author="Author A" Catalog="Business"/>
                    <Item ID="2" Name="Book 2" Price="$0.00" Author="Author B" Catalog="Language"/>
                    <Item ID="3" Name="Book 3" Price="$19.00" Author="Author C" Catalog="Language"/>
                    <Item ID="4" Name="Book 4" Price="$81.50" Author="Author D" Catalog="Business"/>
                    <Item ID="5" Name="Book 5" Price="$9.00" Author="Author E" Catalog="Health"/>
                    <Item ID="6" Name="Book 6" Price="$18.50" Author="Author F" Catalog="Language"/>
                </Info>
            </x:XData>
        </XmlDataProvider>
        <CollectionViewSource x:Key='src' Source="{Binding Source={StaticResource MyData}, XPath=Item}">
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="@Catalog" />
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>
    </Window.Resources>

    <ListView ItemsSource='{Binding Source={StaticResource src}}' BorderThickness="0">
        <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>
                                            <DockPanel>
                                                <TextBlock FontWeight="Bold" Text="{Binding Path=Name}" 
                                   Margin="5,0,0,0" Width="100"/>
                                                <TextBlock FontWeight="Bold" 
                                   Text="{Binding Path=ItemCount}"/>
                                            </DockPanel>
                                        </Expander.Header>
                                        <Expander.Content>
                                            <ItemsPresenter />
                                        </Expander.Content>
                                    </Expander>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </GroupStyle.ContainerStyle>
            </GroupStyle>
        </ListView.GroupStyle>
        <ListView.View>
            <GridView>
                <GridViewColumn Header="ID" 
                        DisplayMemberBinding="{Binding XPath=@ID}" 
                        Width="200" />
                <GridViewColumn Header="Name" 
                        DisplayMemberBinding="{Binding XPath=@Name}" 
                        Width="240" />
                <GridViewColumn Header="Price" 
                        DisplayMemberBinding="{Binding XPath=@Price}"
                        Width="180" />
                <GridViewColumn Header="Author" 
                        DisplayMemberBinding="{Binding XPath=@Author}" 
                        Width="180" />
            </GridView>
        </ListView.View>
    </ListView>


</Window>

   
    
    
  
Related examples in the same category
1.Create a ListView control that implements a GridView view with CheckBox controls for each row.Create a ListView control that implements a GridView view with CheckBox controls for each row.
2.Use ArrayList as the ListView ItemSourceUse ArrayList as the ListView ItemSource
3.ListView and ListViewItemListView and ListViewItem
4.ListView columnsListView columns
5.Populating ListView rowsPopulating ListView rows
6.Set Binding ListView.ItemsSourceProperty to ListViewSet Binding ListView.ItemsSourceProperty to ListView
7.Create a ListView control that uses a GridView view mode to display a collection of DateTime objects.Create a ListView control that uses a GridView view mode to display a collection of DateTime objects.
8.ListView using GridView.HeaderTemplate and GridViewColumn.CellTemplate propertiesListView using GridView.HeaderTemplate and GridViewColumn.CellTemplate properties
9.Get Bounded item from ListViewGet Bounded item from ListView
10.Create Binding for ListView in codeCreate Binding for ListView in code
11.Use three TextBlocks in one ListViewItemUse three TextBlocks in one ListViewItem
12.Create a ListView control that uses a GridView view mode to display dates.Create a ListView control that uses a GridView view mode to display dates.
13.Use Path to reference Bounded object in ItemSourceUse Path to reference Bounded object in ItemSource
14.Enables sorting of data in ascending or descending order according to the contents of one column.Enables sorting of data in ascending or descending order according to the contents of one column.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.