Silverlight 4 组合框下拉显示不一致

2024-03-26

我有一个 Silverlight 4 应用程序,在窗体底部附近有一个组合框。下拉列表中可以包含大约 30 到 100 个项目。

当我第一次打开 ComboBox 时,没有 SelectedItem,Dropdown 向上打开,大约有 23 个条目可见;只要我不选择某个项目,每次我重新打开下拉菜单时,它都会继续这种行为。一旦我选择了一个项目,此后每次我打开组合框时,它总是向下打开下拉菜单,并且只显示 3 个条目。

我猜测下拉菜单仅限于 3 个项目,因为这是窗口在屏幕上最大化时的底部限制。

即使先前已选择某个项目,如何让它显示更多项目?

下面是一个示例 Silverlight 应用程序,演示了浏览器内和浏览器外的行为。

主页.xaml:

<UserControl x:Class="ComboBox_Test.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="650" d:DesignWidth="1024">

    <Grid x:Name="LayoutRoot" Background="LightSteelBlue" Loaded="MainPage_OnLoaded">
        <Grid.RowDefinitions>
            <RowDefinition Height="3*" MinHeight="25" MaxHeight="25" />
            <RowDefinition Height="35*" MinHeight="200" />
            <RowDefinition Height="10*" MinHeight="70" MaxHeight="70" />
            <RowDefinition Height="30*" MinHeight="230" MaxHeight="230" />
            <RowDefinition Height="*" MinHeight="10" MaxHeight="30" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="12" />
            <ColumnDefinition Width="150" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="12" />
        </Grid.ColumnDefinitions>
        <TextBlock Name="lblData" Text="Data:" Grid.Row="1" Grid.Column="1" />
        <TextBox x:Name="txtData" Grid.Row="1" Grid.Column="2" VerticalScrollBarVisibility="Auto"
                HorizontalScrollBarVisibility="Auto" />
        <StackPanel x:Name="AccessPanel" Orientation="Vertical" HorizontalAlignment="Left" Margin="5"
                Grid.Row="3" Grid.Column="2" Visibility="Visible">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="75" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <StackPanel x:Name="CreationPanel" Orientation="Vertical" Grid.Row="1">
                    <Grid x:Name="CreationRoot">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="40" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <StackPanel x:Name="TypesPanel" Orientation="Horizontal" Grid.Row="1" Grid.Column="1"
                                        Margin="0 5 0 5">
                            <Grid x:Name="TypesRoot">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="25" />
                                    <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="220" />
                                    <ColumnDefinition Width="220" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="Types" FontFamily="Arial" FontSize="12" FontWeight="Bold"
                                                        Grid.Row="0" Grid.Column="0" />
                                <ComboBox x:Name="cboTypes" Width="220" Height="30" Grid.Row="1" Grid.Column="0"
                                                        IsEnabled="True"
                                                        SelectionChanged="cboTypes_SelectionChanged">
                                    <ComboBox.ItemTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Name, Mode=OneWay}" />
                                        </DataTemplate>
                                    </ComboBox.ItemTemplate>
                                </ComboBox>
                            </Grid>
                        </StackPanel>
                    </Grid>
                </StackPanel>
            </Grid>
        </StackPanel>
    </Grid>
</UserControl>

MainPage.xaml.cs:

using System;
using System.Windows;
using System.Windows.Controls;

namespace ComboBox_Test
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void UpdateDataText(DataTypeDesc oData)
        {
            txtData.Text = String.Format("{0}\n\t{1}", oData.Name, oData.Desc);
        }

        private void MainPage_OnLoaded(object sender, RoutedEventArgs e)
        {
            object[] aDataTypeDescs = new object[] 
            {
                  new DataTypeDesc() {Name = "Boolean", Desc = "A Boolean value"}
                , new DataTypeDesc() {Name = "Byte",    Desc = "An 8-bit unsigned integer"}
                , new DataTypeDesc() {Name = "Char",    Desc = "A Unicode character"}
                , new DataTypeDesc() {Name = "Double",  Desc = "A double-precision floating-point number"}
                , new DataTypeDesc() {Name = "float",   Desc = "A single-precision floating-point number"}
                , new DataTypeDesc() {Name = "Int16",   Desc = "A 16-bit signed integer"}
                , new DataTypeDesc() {Name = "Int32",   Desc = "A 32-bit signed integer"}
                , new DataTypeDesc() {Name = "Int64",   Desc = "A 64-bit signed integer"}
                , new DataTypeDesc() {Name = "SByte",   Desc = "An 8-bit signed integer"}
                , new DataTypeDesc() {Name = "UInt16",  Desc = "A 16-bit unsigned integer"}
                , new DataTypeDesc() {Name = "UInt32",  Desc = "A 32-bit unsigned integer"}
                , new DataTypeDesc() {Name = "UInt64",  Desc = "A 64-bit unsigned integer"}
                , new DataTypeDesc() {Name = "A",       Desc = "The letter A in the alphabet"}
                , new DataTypeDesc() {Name = "B",       Desc = "The letter B in the alphabet"}
                , new DataTypeDesc() {Name = "C",       Desc = "The letter C in the alphabet"}
                , new DataTypeDesc() {Name = "D",       Desc = "The letter D in the alphabet"}
                , new DataTypeDesc() {Name = "E",       Desc = "The letter E in the alphabet"}
                , new DataTypeDesc() {Name = "F",       Desc = "The letter F in the alphabet"}
                , new DataTypeDesc() {Name = "G",       Desc = "The letter G in the alphabet"}
                , new DataTypeDesc() {Name = "H",       Desc = "The letter H in the alphabet"}
                , new DataTypeDesc() {Name = "I",       Desc = "The letter I in the alphabet"}
                , new DataTypeDesc() {Name = "J",       Desc = "The letter J in the alphabet"}
                , new DataTypeDesc() {Name = "K",       Desc = "The letter K in the alphabet"}
                , new DataTypeDesc() {Name = "L",       Desc = "The letter L in the alphabet"}
                , new DataTypeDesc() {Name = "M",       Desc = "The letter M in the alphabet"}
                , new DataTypeDesc() {Name = "N",       Desc = "The letter N in the alphabet"}
                , new DataTypeDesc() {Name = "O",       Desc = "The letter O in the alphabet"}
                , new DataTypeDesc() {Name = "P",       Desc = "The letter P in the alphabet"}
                , new DataTypeDesc() {Name = "Q",       Desc = "The letter Q in the alphabet"}
                , new DataTypeDesc() {Name = "R",       Desc = "The letter R in the alphabet"}
                , new DataTypeDesc() {Name = "S",       Desc = "The letter S in the alphabet"}
                , new DataTypeDesc() {Name = "T",       Desc = "The letter T in the alphabet"}
                , new DataTypeDesc() {Name = "U",       Desc = "The letter U in the alphabet"}
                , new DataTypeDesc() {Name = "V",       Desc = "The letter V in the alphabet"}
                , new DataTypeDesc() {Name = "W",       Desc = "The letter W in the alphabet"}
                , new DataTypeDesc() {Name = "X",       Desc = "The letter X in the alphabet"}
                , new DataTypeDesc() {Name = "Y",       Desc = "The letter Y in the alphabet"}
                , new DataTypeDesc() {Name = "Z",       Desc = "The letter Z in the alphabet"}
            };

            cboTypes.ItemsSource = aDataTypeDescs;
        }

        private void cboTypes_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataTypeDesc oDesc = (DataTypeDesc)(cboTypes.SelectedItem);
            if (oDesc != null)
                UpdateDataText(oDesc);
        }

    }
}

数据类型描述.cs:

using System;

namespace ComboBox_Test
{
    public class DataTypeDesc
    {
        public String Name { get; set; }
        public String Desc { get; set; }
    }
}

您需要编辑基本的 ComboBox 模板并更改名为 Popup 的元素的大小。在此示例中,它已设置为 100 高,现在无论初始列表还是选择后都显示相同的固定高度弹出窗口:

*注意:我使用 Expression Blend 来编辑基本模板的副本(非常详细)。由于元素部分被命名为“Popup”,理论上您可以编写代码来在可视化树中查找该部分并以这种方式修改高度属性。

更改后的页面来源如下:

<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:System="clr-namespace:System;assembly=mscorlib" x:Class="ComboBox_Test.MainPage"
d:DesignHeight="650" d:DesignWidth="1024" mc:Ignorable="d">

    <UserControl.Resources>
        <ControlTemplate x:Key="ValidationToolTipTemplate">
            <Grid x:Name="Root" Margin="5,0" Opacity="0" RenderTransformOrigin="0,0">
                <Grid.RenderTransform>
                    <TranslateTransform x:Name="xform" X="-25"/>
                </Grid.RenderTransform>
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="OpenStates">
                        <VisualStateGroup.Transitions>
                            <VisualTransition GeneratedDuration="0"/>
                            <VisualTransition GeneratedDuration="0:0:0.2" To="Open">
                                <Storyboard>
                                    <DoubleAnimation Duration="0:0:0.2" To="0" Storyboard.TargetProperty="X" Storyboard.TargetName="xform">
                                        <DoubleAnimation.EasingFunction>
                                            <BackEase Amplitude=".3" EasingMode="EaseOut"/>
                                        </DoubleAnimation.EasingFunction>
                                    </DoubleAnimation>
                                    <DoubleAnimation Duration="0:0:0.2" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root"/>
                                </Storyboard>
                            </VisualTransition>
                        </VisualStateGroup.Transitions>
                        <VisualState x:Name="Closed">
                            <Storyboard>
                                <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root"/>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Open">
                            <Storyboard>
                                <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="X" Storyboard.TargetName="xform"/>
                                <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root"/>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Border Background="#052A2E31" CornerRadius="5" Margin="4,4,-4,-4"/>
                <Border Background="#152A2E31" CornerRadius="4" Margin="3,3,-3,-3"/>
                <Border Background="#252A2E31" CornerRadius="3" Margin="2,2,-2,-2"/>
                <Border Background="#352A2E31" CornerRadius="2" Margin="1,1,-1,-1"/>
                <Border Background="#FFDC000C" CornerRadius="2"/>
                <Border CornerRadius="2">
                    <TextBlock Foreground="White" MaxWidth="250" Margin="8,4,8,4" TextWrapping="Wrap" Text="{Binding (Validation.Errors)[0].ErrorContent}" UseLayoutRounding="false"/>
                </Border>
            </Grid>
        </ControlTemplate>
        <Style x:Key="ComboBoxStyle1" TargetType="ComboBox">
            <Setter Property="Padding" Value="6,2,25,2"/>
            <Setter Property="Background" Value="#FF1F3B53"/>
            <Setter Property="HorizontalContentAlignment" Value="Left"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="TabNavigation" Value="Once"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
            <Setter Property="BorderBrush">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFA3AEB9" Offset="0"/>
                        <GradientStop Color="#FF8399A9" Offset="0.375"/>
                        <GradientStop Color="#FF718597" Offset="0.375"/>
                        <GradientStop Color="#FF617584" Offset="1"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ComboBox">
                        <Grid>
                            <Grid.Resources>
                                <Style x:Name="comboToggleStyle" TargetType="ToggleButton">
                                    <Setter Property="Foreground" Value="#FF333333"/>
                                    <Setter Property="Background" Value="#FF1F3B53"/>
                                    <Setter Property="BorderBrush">
                                        <Setter.Value>
                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Color="#FFA3AEB9" Offset="0"/>
                                                <GradientStop Color="#FF8399A9" Offset="0.375"/>
                                                <GradientStop Color="#FF718597" Offset="0.375"/>
                                                <GradientStop Color="#FF617584" Offset="1"/>
                                            </LinearGradientBrush>
                                        </Setter.Value>
                                    </Setter>
                                    <Setter Property="BorderThickness" Value="1"/>
                                    <Setter Property="Padding" Value="3"/>
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="ToggleButton">
                                                <Grid>
                                                    <VisualStateManager.VisualStateGroups>
                                                        <VisualStateGroup x:Name="CommonStates">
                                                            <VisualState x:Name="Normal"/>
                                                            <VisualState x:Name="MouseOver">
                                                                <Storyboard>
                                                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundOverlay"/>
                                                                    <ColorAnimation Duration="0" To="#7FFFFFFF" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/>
                                                                    <ColorAnimation Duration="0" To="#CCFFFFFF" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/>
                                                                    <ColorAnimation Duration="0" To="#F2FFFFFF" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/>
                                                                </Storyboard>
                                                            </VisualState>
                                                            <VisualState x:Name="Pressed">
                                                                <Storyboard>
                                                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundOverlay2"/>
                                                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Highlight"/>
                                                                    <ColorAnimation Duration="0" To="#E5FFFFFF" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/>
                                                                    <ColorAnimation Duration="0" To="#BCFFFFFF" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/>
                                                                    <ColorAnimation Duration="0" To="#6BFFFFFF" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/>
                                                                    <ColorAnimation Duration="0" To="#F2FFFFFF" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/>
                                                                </Storyboard>
                                                            </VisualState>
                                                            <VisualState x:Name="Disabled"/>
                                                        </VisualStateGroup>
                                                        <VisualStateGroup x:Name="CheckStates">
                                                            <VisualState x:Name="Checked">
                                                                <Storyboard>
                                                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="BackgroundOverlay3"/>
                                                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Highlight"/>
                                                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="BackgroundGradient2"/>
                                                                    <ColorAnimation Duration="0" To="#E5FFFFFF" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient2"/>
                                                                    <ColorAnimation Duration="0" To="#BCFFFFFF" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient2"/>
                                                                    <ColorAnimation Duration="0" To="#6BFFFFFF" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient2"/>
                                                                    <ColorAnimation Duration="0" To="#F2FFFFFF" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient2"/>
                                                                </Storyboard>
                                                            </VisualState>
                                                            <VisualState x:Name="Unchecked"/>
                                                        </VisualStateGroup>
                                                        <VisualStateGroup x:Name="FocusStates">
                                                            <VisualState x:Name="Focused">
                                                                <Storyboard>
                                                                    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="FocusVisualElement">
                                                                        <DiscreteObjectKeyFrame KeyTime="0">
                                                                            <DiscreteObjectKeyFrame.Value>
                                                                                <Visibility>Visible</Visibility>
                                                                            </DiscreteObjectKeyFrame.Value>
                                                                        </DiscreteObjectKeyFrame>
                                                                    </ObjectAnimationUsingKeyFrames>
                                                                </Storyboard>
                                                            </VisualState>
                                                            <VisualState x:Name="Unfocused"/>
                                                        </VisualStateGroup>
                                                    </VisualStateManager.VisualStateGroups>
                                                    <Rectangle x:Name="Background" Fill="{TemplateBinding Background}" RadiusY="3" RadiusX="3" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}"/>
                                                    <Rectangle x:Name="BackgroundOverlay" Fill="#FF448DCA" Opacity="0" RadiusY="3" RadiusX="3" Stroke="#00000000" StrokeThickness="{TemplateBinding BorderThickness}"/>
                                                    <Rectangle x:Name="BackgroundOverlay2" Fill="#FF448DCA" Opacity="0" RadiusY="3" RadiusX="3" Stroke="#00000000" StrokeThickness="{TemplateBinding BorderThickness}"/>
                                                    <Rectangle x:Name="BackgroundGradient" Margin="{TemplateBinding BorderThickness}" RadiusY="2" RadiusX="2" Stroke="#FFFFFFFF" StrokeThickness="1">
                                                        <Rectangle.Fill>
                                                            <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                                                                <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                                                <GradientStop Color="#F9FFFFFF" Offset="0.375"/>
                                                                <GradientStop Color="#E5FFFFFF" Offset="0.625"/>
                                                                <GradientStop Color="#C6FFFFFF" Offset="1"/>
                                                            </LinearGradientBrush>
                                                        </Rectangle.Fill>
                                                    </Rectangle>
                                                    <Rectangle x:Name="BackgroundOverlay3" Fill="#FF448DCA" Opacity="0" RadiusY="3" RadiusX="3" Stroke="#00000000" StrokeThickness="{TemplateBinding BorderThickness}"/>
                                                    <Rectangle x:Name="BackgroundGradient2" Margin="{TemplateBinding BorderThickness}" Opacity="0" RadiusY="2" RadiusX="2" Stroke="#FFFFFFFF" StrokeThickness="1">
                                                        <Rectangle.Fill>
                                                            <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                                                                <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                                                <GradientStop Color="#F9FFFFFF" Offset="0.375"/>
                                                                <GradientStop Color="#E5FFFFFF" Offset="0.625"/>
                                                                <GradientStop Color="#C6FFFFFF" Offset="1"/>
                                                            </LinearGradientBrush>
                                                        </Rectangle.Fill>
                                                    </Rectangle>
                                                    <Rectangle x:Name="Highlight" IsHitTestVisible="false" Margin="{TemplateBinding BorderThickness}" Opacity="0" RadiusY="2" RadiusX="2" Stroke="#FF6DBDD1" StrokeThickness="1"/>
                                                    <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                                    <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="false" Margin="1" RadiusY="3.5" RadiusX="3.5" Stroke="#FF6DBDD1" StrokeThickness="1" Visibility="Collapsed"/>
                                                </Grid>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </Grid.Resources>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver"/>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="00:00:00" To=".55" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="DisabledVisualElement"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused">
                                        <Storyboard>
                                            <DoubleAnimation Duration="00:00:00" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="FocusVisualElement"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Unfocused"/>
                                    <VisualState x:Name="FocusedDropDown">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="00:00:00" Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="PopupBorder">
                                                <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="ValidationStates">
                                    <VisualState x:Name="Valid"/>
                                    <VisualState x:Name="InvalidUnfocused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ValidationErrorElement">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="InvalidFocused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ValidationErrorElement">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsOpen" Storyboard.TargetName="validationTooltip">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <System:Boolean>True</System:Boolean>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border x:Name="ContentPresenterBorder">
                                <Grid>
                                    <ToggleButton x:Name="DropDownToggle" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Right" Margin="0" Style="{StaticResource comboToggleStyle}" VerticalAlignment="Stretch">
                                        <Path x:Name="BtnArrow" Data="F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z " HorizontalAlignment="Right" Height="4" Margin="0,0,6,0" Stretch="Uniform" Width="8">
                                            <Path.Fill>
                                                <SolidColorBrush x:Name="BtnArrowColor" Color="#FF333333"/>
                                            </Path.Fill>
                                        </Path>
                                    </ToggleButton>
                                    <ContentPresenter x:Name="ContentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                        <TextBlock Text=" "/>
                                    </ContentPresenter>
                                </Grid>
                            </Border>
                            <Rectangle x:Name="DisabledVisualElement" Fill="White" IsHitTestVisible="false" Opacity="0" RadiusY="3" RadiusX="3"/>
                            <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="false" Margin="1" Opacity="0" RadiusY="2" RadiusX="2" Stroke="#FF6DBDD1" StrokeThickness="1"/>
                            <Border x:Name="ValidationErrorElement" BorderBrush="#FFDB000C" BorderThickness="1" CornerRadius="1" Visibility="Collapsed">
                                <ToolTipService.ToolTip>
                                    <ToolTip x:Name="validationTooltip" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}" Placement="Right" PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Template="{StaticResource ValidationToolTipTemplate}">
                                        <ToolTip.Triggers>
                                            <EventTrigger RoutedEvent="Canvas.Loaded">
                                                <BeginStoryboard>
                                                    <Storyboard>
                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsHitTestVisible" Storyboard.TargetName="validationTooltip">
                                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                                <DiscreteObjectKeyFrame.Value>
                                                                    <System:Boolean>true</System:Boolean>
                                                                </DiscreteObjectKeyFrame.Value>
                                                            </DiscreteObjectKeyFrame>
                                                        </ObjectAnimationUsingKeyFrames>
                                                    </Storyboard>
                                                </BeginStoryboard>
                                            </EventTrigger>
                                        </ToolTip.Triggers>
                                    </ToolTip>
                                </ToolTipService.ToolTip>
                                <Grid Background="Transparent" HorizontalAlignment="Right" Height="12" Margin="1,-4,-4,0" VerticalAlignment="Top" Width="12">
                                    <Path Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z" Fill="#FFDC000C" Margin="1,3,0,0"/>
                                    <Path Data="M 0,0 L2,0 L 8,6 L8,8" Fill="#ffffff" Margin="1,3,0,0"/>
                                </Grid>
                            </Border>
                            <Popup x:Name="Popup">
                                <Border x:Name="PopupBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3" HorizontalAlignment="Stretch" Height="100">
                                    <Border.Background>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                            <GradientStop Color="#FFFEFEFE" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Border.Background>
                                    <ScrollViewer x:Name="ScrollViewer" BorderThickness="0" Padding="1">
                                        <ItemsPresenter/>
                                    </ScrollViewer>
                                </Border>
                            </Popup>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="LightSteelBlue" Loaded="MainPage_OnLoaded">
        <Grid.RowDefinitions>
            <RowDefinition Height="3*" MinHeight="25" MaxHeight="25" />
            <RowDefinition Height="35*" MinHeight="200" />
            <RowDefinition Height="10*" MinHeight="70" MaxHeight="70" />
            <RowDefinition Height="30*" MinHeight="230" MaxHeight="230" />
            <RowDefinition Height="*" MinHeight="10" MaxHeight="30" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="12" />
            <ColumnDefinition Width="150" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="12" />
        </Grid.ColumnDefinitions>
        <TextBlock x:Name="lblData" Text="Data:" Grid.Row="1" Grid.Column="1" />
        <TextBox x:Name="txtData" Grid.Row="1" Grid.Column="2" VerticalScrollBarVisibility="Auto"
                HorizontalScrollBarVisibility="Auto" />
        <StackPanel x:Name="AccessPanel" Orientation="Vertical" HorizontalAlignment="Left" Margin="5"
                Grid.Row="3" Grid.Column="2" Visibility="Visible">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="75" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <StackPanel x:Name="CreationPanel" Orientation="Vertical" Grid.Row="1">
                    <Grid x:Name="CreationRoot">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="40" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <StackPanel x:Name="TypesPanel" Orientation="Horizontal" Grid.Row="1" Grid.Column="1"
                                        Margin="0 5 0 5">
                            <Grid x:Name="TypesRoot">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="25" />
                                    <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="220" />
                                    <ColumnDefinition Width="220" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="Types" FontFamily="Arial" FontSize="12" FontWeight="Bold"
                                                        Grid.Row="0" Grid.Column="0" />
                                <ComboBox x:Name="cboTypes" Width="220" Height="30" Grid.Row="1" Grid.Column="0"
                                                        IsEnabled="True"
                                                        SelectionChanged="cboTypes_SelectionChanged" MaxDropDownHeight="600" Style="{StaticResource ComboBoxStyle1}">
                                    <ComboBox.ItemTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Name, Mode=OneWay}" />
                                        </DataTemplate>
                                    </ComboBox.ItemTemplate>
                                </ComboBox>
                            </Grid>
                        </StackPanel>
                    </Grid>
                </StackPanel>
            </Grid>
        </StackPanel>
    </Grid>
</UserControl>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Silverlight 4 组合框下拉显示不一致 的相关文章

随机推荐

  • dask 中不支持项目分配的解决方法

    我正在尝试将我的代码库从 numpy 数组转换为 dask 因为我的 numpy 数组超出了Memory Error限制 但是 我发现可变数组的功能尚未实现dask arrays所以我得到了 NotImplementedError Item
  • 谁能给我解释一下 C++ 异常规范吗?

    谁能解释一下 C 中使用的异常规范 它们什么时候使用 我很少看到它在代码中使用 使用异常规范的优点和缺点 优点 缺点 是什么 它们什么时候使用 我很少看到它在代码中使用 希望永远不会 因为它们在明年标准化的下一版本 C 中已被弃用 使用异常
  • 如何修复错误“您可能需要适当的加载程序来处理此文件类型”

    我有一个全新的 Laravel 安装 关于使用编译文件npm run dev VUE我收到文件错误 您可能需要适当的加载程序来处理此文件类型 当前没有配置加载程序来处理此文件 Laravel 版本 8 12 包 json devDepend
  • Facebook 评论镜像不起作用

    我一步一步做了这些 创建一个新的 Facebook 应用程序 应用程序 ID 544557495732050 创建一个新的 Facebook 页面 https www facebook com Pasha Electronic 502844
  • 每秒(或更短时间)检查 url 是否有效的最佳方法是什么,在 C# 窗口窗体应用程序 (.NET) 中使用 Task wait 或 ContinueWith

    我是 C Net 和 Visual Studio 2022 的新手 我想要实现的是每秒运行一个计时器来检查网站 url 是否有效 是否已启动 如果 url 可访问并且当前 WebView2 未显示该网站 那么它应该导航到该网站 如果它已经显
  • TypeScript 泛型:无效、从不或未定义? [关闭]

    Closed 这个问题需要细节或清晰度 help closed questions 目前不接受答案 总是想知道这个问题 所以想要得到一个明确的答案并将其固定下来 我想做的是让编译器 语言服务 阅读器知道T应该什么都没有 空的 虚无 我想知道
  • 跨计算机快速同步 git 工作区

    我有一个使用 git 的个人项目 我经常在多台计算机上进行 hack 托管在 Github 上 因为我在家做这件事 所以经常被打扰 我正在发表声明 晚餐已经准备好了 否则我需要换尿布 当我重新开始编码时 我可能会使用另一台计算机 获取最新版
  • 如何在 iPhone 的自定义 UIView 上启用 UIDragInteraction

    我一直在尝试使用 Apple 的新 API 来启用自定义 UIView 上的拖动交互 我在使用 iPad 进行测试时成功地使其工作 但是当我在 iPhone 7 ios 11 beta 3 中运行相同的应用程序时 我无法拖动我的自定义 UI
  • SQL Server:将 bool 转换为整数

    为什么查询 SELECT CAST column LIKE string AS INT 100 return 关键字 AS 附近的语法不正确 因为 bool 不是 T SQL 中的类型 它不存在 布尔表达式不是位类型 他们不have类型 仅
  • 如何在 Polymer 1.0 中过滤铁列表?

    The dom repeat元素提供了一个filter属性 有没有类似的过滤方法iron list 例如 给定一个人员列表 我想过滤出生在特定城市的人 As iron list不幸的是不提供filter属性 没有声明性模式使这成为可能 您可
  • ActiveRecord:如何找到所有孩子都符合条件的父母?

    假设我有一个Parent模型有很多Child 然后Child也属于OtherParent 我怎样才能找到全部Parent其中所有的Child属于任何OtherParent 在纯 SQL 中我可以做 Parent find by sql lt
  • PySpark 可以使用 numpy 数组吗?

    我尝试在 pyspark 会话中执行以下命令 gt gt gt a 1 2 3 4 5 6 7 8 9 10 gt gt gt da sc parallelize a gt gt gt da reduce lambda a b a b 效果
  • 我的 onChange 不适用于反应

    我已经关注了这个文档 https facebook github io react docs forms html why select value并使用 React 创建了一个选择标签 我已经编辑了这个问题 如果我在选择中使用 class
  • 无法更新公司防火墙后面的 conda 软件包。更新了 .condarc 文件,代理设置仍然要求代理用户名和密码

    我位于公司防火墙后面 我正在尝试通过运行以下命令来更新 conda 软件包 conda update all 这是要求我提供代理用户名和密码 https proxy username https proxy username Passwor
  • 公开存储库的子集,同时保留历史记录

    我有一些受版本控制的代码 使用 Mercurial 并且想分享其中的一些代码 同时隐藏我无法发布到公共领域的其他部分 至少在现阶段 理想情况下 我希望保持公共代码的修订历史记录完整 更重要的是 能够在公共存储库和包含公共和私有代码的存储库之
  • 计算列表内列表之间的最小长度

    a 1 0 1 2 1 1 1 3111111 31 1 4 51 1 1 1 1 1 6 7 8 print min a 0 a 1 a 2 以下代码返回 1 0 1 2 1 1 1 3111111 不确定默认键是什么以及根据什么逻辑返回
  • 如何在购物篮中显示正确的税费(结账前)?

    我有一个简单的问题 我为不同国家设置了多种税率 但是 在购物篮页面上 当尚未访问结帐页面时 它会显示来自基准国家 地区的税费 就我而言 我在 AT 有一家商店 我已经为 AT 和 CH 设置了税费 如果用户使用瑞士 IP 进行访问 我会将国
  • 合并多个data.table

    我知道一个人可以合并 加入 两个data table与merge函数或 data table功能 然而 如果我说 10 data table并想要使用do call将它们全部合并在一起 是否有一个函数可以做到这一点 目前我求助于do cal
  • 覆盖 Object.toString 错误

    为什么这会在 Flash Builder 中产生错误 package public class Foo override public function toString String return Foo 制表符补全表明这可用于覆盖 错误
  • Silverlight 4 组合框下拉显示不一致

    我有一个 Silverlight 4 应用程序 在窗体底部附近有一个组合框 下拉列表中可以包含大约 30 到 100 个项目 当我第一次打开 ComboBox 时 没有 SelectedItem Dropdown 向上打开 大约有 23 个