我在我的应用中使用了ComboBox控件。我知道没有支持的Metro主题 - 但是ComboBox完全符合我的需求,所以我们就是......所以我的困境是我需要从头开始创建一个地铁主题,或者我需要花两天时间来重新创建ComboBox控件。我尝试了第一个选项(创建地铁主题),但遇到了一些问题:
我玩过Blend for HOURS并且无法看到如何更改这些值。任何帮助非常感谢。这是我目前的风格:
<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>
答案 0 :(得分:0)
支持您的实际问题Alex Yakhnin has created a ListPicker control,这可能是您的合适选择。它也非常符合地铁风格 它也是开源的,所以你可以深入研究代码,看看他是如何处理主题的。
答案 1 :(得分:0)
新的silverlight工具包已经发布,它有你想要的listpicker。
最好使用这个,因为它经过了很好的测试,而不是创建自己的,并为错误打开了大门。