|
<Window x:Class="UserControlAsDataTemplateDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:UserControls="clr-namespace:UserControlAsDataTemplateDemo.UserControls"
Title="User Control As Data Template"
Height="500" Width="1000"
Background="{DynamicResource WindowBackgroundBrush}">
<Window.Resources>
<Style x:Key="ListBoxItemStretch" TargetType="{x:Type ListBoxItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Background" Value="Transparent" />
</Style>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.928*"/>
<RowDefinition Height="0.072*"/>
</Grid.RowDefinitions>
<ListBox x:Name="peopleListBox"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ItemContainerStyle="{StaticResource ListBoxItemStretch}"
Foreground="Transparent"
BorderBrush="Transparent"
Background="Transparent"
Grid.ColumnSpan="2">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<UserControls:ItemTemplateControl Margin="4" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button x:Name="btnLoadData"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Content="Load Data"
Grid.Row="1"
Click="btnLoadData_Click"
Grid.ColumnSpan="1" />
<Button x:Name="btnClearData"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Content="Clear Data"
Grid.Row="1"
Grid.Column="1" Click="btnClearData_Click" />
</Grid>
</Window>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.