1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
<Window x:Class="WpfSelectButton.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System.Collections;assembly=mscorlib"
xmlns:local="clr-namespace:WpfSelectButton"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<sys:ArrayList x:Key="liste">
<local:LeItem ID="100" Name="kropernic"/>
<local:LeItem ID="200" Name="mabrouki"/>
<local:LeItem ID="300" Name="inconnu"/>
</sys:ArrayList>
<DataTemplate x:Key="templateLeItem" >
<StackPanel Orientation="Horizontal" >
<TextBlock Margin="5" Text="{Binding ID}"/>
<TextBlock Margin="5" Text="{Binding Name}"/>
</StackPanel>
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<local:SelectButton
Height="30" Width="100"
Click="SelectButton_Click"
ItemTemplate="{StaticResource templateLeItem}"
ItemsSource="{Binding Source={StaticResource liste}}"
SelectionChanged="SelectButton_SelectionChanged" >
</local:SelectButton>
<StackPanel Grid.Row="1" Background="AliceBlue" >
<TextBlock x:Name="tb1" Text=""></TextBlock>
<TextBlock x:Name="tb2" Text=""></TextBlock>
<ListBox
x:Name="lb"
Height="100"
ItemTemplate="{StaticResource templateLeItem}" >
</ListBox>
</StackPanel>
</Grid>
</Window> |
Partager