miércoles, 24 de enero de 2007

HeaderedItemsControl with a GridView look sample

This is a basic sample of HeaderedItemsControl, that shows a set of values in a table, or GridView like look view.


The Visual Studio project can be downloaded here.

Here's the code, if you know any better way to accomplish this tell me.



<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xml:lang="en-US"
x:Class="HeaderedItemsGridView.Window1"
x:Name="Window"
Title="Window"
Width="400" Height="300">
<Window.Resources>
<XmlDataProvider Source="Data.xml" x:Key="dataDS"/>
<DataTemplate x:Key="personTemplate">
<Grid Width="Auto" Background="#e1e1e1">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="{Binding Mode=OneWay, XPath=@name}" />
<Label Grid.Column="1" Content="{Binding Mode=OneWay, XPath=@surname}" />
<Label Grid.Column="2" Content="{Binding Mode=OneWay, XPath=@age}" />
<Label Grid.Column="3" Content="{Binding Mode=OneWay, XPath=@phone}"/>
</Grid>
</DataTemplate>

<Style TargetType="{x:Type HeaderedItemsControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type HeaderedItemsControl}">
<Grid Background="Red" Margin="50,50,50,50">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20pt"/>
<RowDefinition Height="4*"/>
</Grid.RowDefinitions>
<Label Grid.Column="0" Grid.Row="0" Content="Name"/>
<Label Grid.Column="1" Grid.Row="0" Content="Surname"/>
<Label Grid.Column="2" Grid.Row="0" Content="Age"/>
<Label Grid.Column="3" Grid.Row="0" Content="Phone"/>
<Grid Grid.Row="1" Grid.ColumnSpan="4" Width="Auto" Height="Auto" Background="White">
<ItemsPresenter/>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>

<Grid x:Name="MainWindow">
<HeaderedItemsControl
x:Name="MyGridList"
ItemTemplate="{DynamicResource personTemplate}"
ItemsSource="{Binding Mode=Default, Source={StaticResource dataDS}, XPath=/data/persons/person}"/>
</Grid>
</Window>



The result looks like this:


WPF HeaderedItemsControl sample

2 comentarios:

Video Teraveloka dijo...

Pembahasan kali ini teruntuk kamu yang sedang kesulitan login akun sbobet karena muncul keterangan "Sbobet Password Policy". Jangan panik karena kamu hanya diperintahkan untuk Ganti Password Sbobet Online milik (Baca Selengkapnya Disini...)

magdalineraciti dijo...

Play the Best Casino Games at Poormans Gods Casino
The site 블랙 잭 룰 offers over 1000 games pcie 슬롯 and many of 카드 카운팅 them pay great bonuses. 에그 벳 They are 12bet all highly reputable, as well as licensed.