Silverlight 4.0 Windows Phone组合框样式存在问题
我正在应用程序中使用ComboBox控件。我知道它没有支持的Metro主题-但是一个组合框非常适合我的需要,所以我们在这里。。。所以我的困境是,我需要从头开始创建metro主题,或者我需要花2天的时间重新创建ComboBox控件。我尝试了第一种选择(创建metro主题),但遇到了一些问题:Silverlight 4.0 Windows Phone组合框样式存在问题,silverlight-4.0,windows-phone-7,Silverlight 4.0,Windows Phone 7,我正在应用程序中使用ComboBox控件。我知道它没有支持的Metro主题-但是一个组合框非常适合我的需要,所以我们在这里。。。所以我的困境是,我需要从头开始创建metro主题,或者我需要花2天的时间重新创建ComboBox控件。我尝试了第一种选择(创建metro主题),但遇到了一些问题: 文本始终为白色-不知道如何设置 我无法更改选择框的颜色(不是下拉列表) 我无法更改下拉列表的颜色 我在Blend上玩了几个小时,看不出如何更改这些值。非常感谢您的帮助。以下是我目前的风格: <S
<Style x:Key="ComboBoxItemStyle" TargetType="ComboBoxItem">
<Setter Property="Background" Value="{x:Null}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBoxItem">
<Border x:Name="LayoutRoot"
BorderThickness="{TemplateBinding BorderThickness}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver"/>
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ContentContainer"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected"/>
<VisualState x:Name="Selected"/>
<VisualState x:Name="SelectedUnfocused"/>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Unfocused"/>
<VisualState x:Name="Focused"/>
</VisualStateGroup>
<VisualStateGroup x:Name="LayoutStates">
<VisualState x:Name="AfterLoaded"/>
<VisualState x:Name="BeforeLoaded"/>
<VisualState x:Name="BeforeUnloaded"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentControl x:Name="ContentContainer"
Background="Yellow"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Foreground="{StaticResource PhoneAccentBrush}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ItemsPanelTemplate x:Key="ComboxBoxItemsTemplate">
<StackPanel Background="Green"/>
</ItemsPanelTemplate>
<Style x:Key="ComboBoxStyle" TargetType="ComboBox">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="ItemContainerStyle" Value="{StaticResource ComboBoxItemStyle}" />
<Setter Property="ItemsPanel" Value="{StaticResource ComboxBoxItemsTemplate}" />
<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
<!-- The hue of the combo box selection box (not the drop down) -->
<Setter Property="Background" Value="{StaticResource PhoneBackgroundBrush}"/>
<!-- Effects BorderBrush for selection box and drop down -->
<Setter Property="BorderBrush" Value="Transparent"/>
<!-- Effects BorderThickness for selection box and drop down -->
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="6"/>
</Style>
回避您的实际问题,这可能是适合您的选择。它也非常适合地铁风格。
它也是开源的,所以你可以深入了解代码,看看他是如何处理主题的。新的silverlight工具包已经发布,它有你想要的listpicker
最好使用这一个,因为它经过了很好的测试,而不是创建自己的,为bug打开大门。太好了,这正是我想要的。我想微软团队的主要想法是“我们如何提供一个坚实的核心?”像这样的UI元素,虽然非常非常好,但可以开箱即用(比如Alex的博客等)。另一方面,核心功能必须经过平台的所有QA和测试,然后必须等待整个beast准备好装运。我认为通过博客、Codeplex等进行带外发布实际上是不可靠的,因为与等待正式发布相比,它可以更快地发布和升级功能。嗨,Will,团队正在就Windows Phone Developer Toolkit中包含的控件咨询社区。ListPicker已经长大了。谢谢Mick。只是好奇,你们是如何与社区协商的?有没有一个页面可以让我添加我的愿望清单?谢谢