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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
<Window x:Class="WpfToggleButton.Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfToggleButton"
Title="Window2" Height="300" Width="300">
<Window.Resources>
<local:ListPorts x:Key="MyDataSource"></local:ListPorts>
<local:BooleanToStringValueConverter x:Key="BooleanToIntValueConverter" />
</Window.Resources>
<Grid DataContext="{Binding Source={StaticResource MyDataSource},Path=. }">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel
Grid.Row="0"
Grid.Column="0"
Name="StackPanel1"
Background="Aqua">
<RadioButton
Name="RadioButton1"
GroupName="Group1"
Content="ID1"
IsChecked="{Binding Path=ID1,
Converter={StaticResource BooleanToIntValueConverter},
ConverterParameter=1}" />
<RadioButton
Name="RadioButton2"
GroupName="Group1"
Content="ID2"
IsChecked="{Binding Path=ID1,
Converter={StaticResource BooleanToIntValueConverter},
ConverterParameter=2}" />
<RadioButton
Name="RadioButton3"
GroupName="Group1"
Content="ID3"
IsChecked="{Binding Path=ID1,
Converter={StaticResource BooleanToIntValueConverter},
ConverterParameter=3}" />
</StackPanel>
<StackPanel
Grid.Row="0"
Grid.Column="1"
Name="StackPanel2"
Background="Yellow" >
<RadioButton
Name="RadioButton4"
GroupName="Group2"
Content="ID4"
IsChecked="{Binding Path=ID2,
Converter={StaticResource BooleanToIntValueConverter},
ConverterParameter=4}" />
<RadioButton
Name="RadioButton5"
GroupName="Group2"
Content="ID5"
IsChecked="{Binding Path=ID2,
Converter={StaticResource BooleanToIntValueConverter},
ConverterParameter=5}" />
<RadioButton
Name="RadioButton6"
GroupName="Group2"
Content="ID6"
IsChecked="{Binding Path=ID2,
Converter={StaticResource BooleanToIntValueConverter},
ConverterParameter=6}" />
</StackPanel>
<ListBox
Grid.Row="1"
Grid.ColumnSpan="2"
BorderBrush="DarkBlue"
BorderThickness="5"
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type local:Port}">
<StackPanel
Orientation="Horizontal" >
<TextBlock
Margin="10" Text="{Binding Name1}"/>
<TextBlock
Margin="10" Text="{Binding ID1}"/>
<TextBlock
Margin="10" Text="{Binding Name2}"/>
<TextBlock
Margin="10" Text="{Binding ID2}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Window> |
Partager