带装饰器的ComboBox
样式
1 <UserControl.Resources> 2 <Style TargetType="GroupBox"> 3 <Setter Property="Margin" Value="0,5"/> 4 <Setter Property="Template"> 5 <Setter.Value> 6 <ControlTemplate TargetType="GroupBox"> 7 <Grid> 8 <Grid.RowDefinitions> 9 <RowDefinition Height="Auto" /> 10 <RowDefinition Height="*" /> 11 </Grid.RowDefinitions> 12 <StackPanel Orientation="Horizontal"> 13 <TextBlock Text="{TemplateBinding Header}" Foreground="#FF08113C" FontSize="20"/> 14 <TextBlock Text="{TemplateBinding Tag}" Foreground="#FF08113C" VerticalAlignment="Bottom" FontSize="14" Margin="15,0,0,0"/> 15 </StackPanel> 16 17 <Border Grid.Row="1" BorderThickness="1" BorderBrush="#FF2BB6FE" Margin="0,7,5,5" Name="bor"> 18 <!--应用了这个模板的控件的Content属性的内容放到这个对象中--> 19 <ContentPresenter/> 20 </Border> 21 22 <!--装饰--> 23 <Grid Grid.Row="1" Margin="0,7,0,0"> 24 <Border BorderBrush="#447D96C4" BorderThickness="0,0,1,1" Margin="5,5,0,0"/> 25 <Line X1="0" Y1="0" X2="5" Y2="0" Stroke="#447D96C4" StrokeThickness="1" 26 HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,5,0,0"/> 27 <Line X1="0" Y1="0" X2="0" Y2="5" Stroke="#447D96C4" StrokeThickness="1" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="5,0,0,0"/> 28 <Polyline Points="5 0 0 0 0 5" Stroke="#FF08113C" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="1"/> 29 <Polyline Points="0 0 5 0 5 5" Stroke="#FF08113C" VerticalAlignment="Top" HorizontalAlignment="Right" Grid.Row="1" Margin="0,0,5,0"/> 30 <Polyline Points="0 5 5 5 5 0" Stroke="#FF08113C" VerticalAlignment="Bottom" HorizontalAlignment="Right" Grid.Row="1" Margin="0,0,5,5"/> 31 <Polyline Points="0 0 0 5 5 5" Stroke="#FF08113C" VerticalAlignment="Bottom" HorizontalAlignment="Left" Grid.Row="1" Margin="0,0,0,5"/> 32 </Grid> 33 </Grid> 34 </ControlTemplate> 35 </Setter.Value> 36 </Setter> 37 </Style> 38 </UserControl.Resources>
调用
1 <GroupBox Grid.Column="1" Header="温度设定" Tag="Temperature Setting" TextBlock.Foreground="#FF08113C" Margin="10,0,0,0" FontSize="20"> 2 <UniformGrid Columns="1"> 3 <StackPanel Orientation="Horizontal"> 4 <TextBlock Text="显示温度:" FontSize="20" Width="120" Height="25" Margin="10,0"/> 5 <TextBlock Text="{Binding TempDisplay}" FontSize="40" Height="50" Width="150" Background="AliceBlue" Foreground="Red"/> 6 </StackPanel> 7 <StackPanel Orientation="Horizontal"> 8 <TextBlock Text="设定温度:" FontSize="20" Width="120" Height="25" Margin="10,0"/> 9 <TextBox Width="150" Height="40" Text="{Binding SVSetting}" Foreground="Green"/> 10 </StackPanel> 11 12 13 14 <StackPanel Orientation="Horizontal"> 15 <TextBlock Text="范围最高值:" FontSize="20" Width="120" Height="25" Margin="10,0"/> 16 <TextBox Width="150" Height="40" Text="{Binding InHTemp}"/> 17 </StackPanel> 18 <StackPanel Orientation="Horizontal"> 19 <TextBlock Text="范围最低值:" FontSize="20" Width="120" Height="25" Margin="10,0"/> 20 <TextBox Width="150" Height="40" Text="{Binding InLTemp}"/> 21 </StackPanel> 22 <StackPanel Orientation="Horizontal"> 23 <TextBlock Text="停止/执行 :" FontSize="20" Width="120" Height="25" Margin="10,0"/> 24 <ComboBox Width="150" Height="40" SelectedIndex="{Binding StopRunModel}"> 25 <ComboBoxItem Content="停止"/> 26 <ComboBoxItem Content="执行"/> 27 </ComboBox> 28 </StackPanel> 29 </UniformGrid> 30 </GroupBox>

浙公网安备 33010602011771号