The default GroupStyle indents the items in a group : Grid « Windows Presentation Foundation « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Windows Presentation Foundation » Grid 
16.34.24.The default GroupStyle indents the items in a group
<Window 
    x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:WpfApplication1="clr-namespace:WpfApplication1"
    Title="WPF" Height="300" Width="160">

    <Window.Resources>
        <WpfApplication1:Countries x:Key="countries"/>
        <WpfApplication1:GroupByContinentConverter x:Key="GroupByContinentConverter"/>
        <CollectionViewSource 
            x:Key="cvs" 
            Source="{Binding Source={StaticResource countries}}">
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription Converter="{StaticResource GroupByContinentConverter}" />
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>
    </Window.Resources>
    <Grid>
        <ItemsControl ItemsSource="{Binding Source={StaticResource cvs}}" DisplayMemberPath="Name" >
            <ItemsControl.GroupStyle>
                <x:Static Member="GroupStyle.Default"/>
            </ItemsControl.GroupStyle>
        </ItemsControl>

    </Grid>
</Window>
//File:Window.xaml.vb

Imports System
Imports System.Globalization
Imports System.Windows.Data
Imports System.Collections.ObjectModel

Namespace WpfApplication1
  Public Class GroupByContinentConverter
    Implements IValueConverter
    Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfoAs Object Implements IValueConverter.Convert
      Dim country As Country = DirectCast(value, Country)
      ' Decide which group the country belongs in
      Select Case country.Continent
        Case Continent.NorthAmerica
          Return "Americas"
        Case Else
          Return "Others"
      End Select
    End Function

    Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfoAs Object Implements IValueConverter.ConvertBack
      Throw New NotImplementedException()
    End Function
  End Class

  Public Class Country
    Private m_name As String
    Private m_continent As Continent

    Public Sub New(name As String, continent As Continent)
      Me.m_name = name
      Me.m_continent = continent
    End Sub

    Public Property Name() As String
      Get
        Return m_name
      End Get
      Set
        m_name = value
      End Set
    End Property

    Public Property Continent() As Continent
      Get
        Return m_continent
      End Get
      Set
        m_continent = value
      End Set
    End Property
  End Class

  Public Enum Continent
    Europe
    NorthAmerica
  End Enum

  Public Class Countries
    Inherits Collection(Of Country)
    Public Sub New()
      Me.Add(New Country("Great Britan", Continent.Europe))
      Me.Add(New Country("USA", Continent.NorthAmerica))
      Me.Add(New Country("Canada", Continent.NorthAmerica))
    End Sub
  End Class
End Namespace
WPF The Default Group Style Indents The Items In A Group
16.34.Grid
16.34.1.The first row of a gridThe first row of a grid
16.34.2.Positioning elements using a GridPositioning elements using a Grid
16.34.3.Layout within a button using GridLayout within a button using Grid
16.34.4.Label in a GridLabel in a Grid
16.34.5.Display Content in Resizable Split PanelDisplay Content in Resizable Split Panel
16.34.6.Place more than two object to one cellPlace more than two object to one cell
16.34.7.Add StackPanel to Row 0Add StackPanel to Row 0
16.34.8.Using the attached properties of GridUsing the attached properties of Grid
16.34.9.Two columns and three rows columnsTwo columns and three rows columns
16.34.10.Fixed column widthFixed column width
16.34.11.Grid with row and column definition and place buttons to grid cellsGrid with row and column definition and place buttons to grid cells
16.34.12.Shared Size GroupsShared Size Groups
16.34.13.DoubleSplit WindowDoubleSplit Window
16.34.14.Use the Grid to create a dialog box that uses the WPF layout APIUse the Grid to create a dialog box that uses the WPF layout API
16.34.15.Is Grid ReadOnlyIs Grid ReadOnly
16.34.16.Dynamically add Button to a Grid and add Action listenerDynamically add Button to a Grid and add Action listener
16.34.17.Setting Grid row heights in codeSetting Grid row heights in code
16.34.18.Layout Controls with Grid in codeLayout Controls with Grid in code
16.34.19.Show Grid lines in codeShow Grid lines in code
16.34.20.Put Button onto a GridPut Button onto a Grid
16.34.21.Use the IsSharedSizeScope attached property of the Grid elementUse the IsSharedSizeScope attached property of the Grid element
16.34.22.Change the margins of an element that is within a Grid by XAML and programmatic codeChange the margins of an element that is within a Grid by XAML and programmatic code
16.34.23.Programmatically use the positioning methods of GridProgrammatically use the positioning methods of Grid
16.34.24.The default GroupStyle indents the items in a groupThe default GroupStyle indents the items in a group
16.34.25.A resizable layoutbased on GridA resizable layoutbased on Grid
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.