C# 组合框风格的windows metro应用程序

C# 组合框风格的windows metro应用程序,c#,xaml,windows-8,microsoft-metro,C#,Xaml,Windows 8,Microsoft Metro,我正在Windows8中开发一个xaml/c#metro风格的应用程序。我想模拟Microsoft日历应用程序组合框样式(在事件详细信息页面中)。我的意思是,在选择后有彩色框和边框的行为。如何使用可视状态执行此操作?此操作没有标准控件,您必须创建自己的/扩展标准组合框类似的操作应该可以: <Combobox.Template> <ControlTemplate> <VisualStateManager.VisualStateGroups>

我正在Windows8中开发一个xaml/c#metro风格的应用程序。我想模拟Microsoft日历应用程序组合框样式(在事件详细信息页面中)。我的意思是,在选择后有彩色框和边框的行为。如何使用可视状态执行此操作?

此操作没有标准控件,您必须创建自己的/扩展标准组合框

类似的操作应该可以:

<Combobox.Template>
    <ControlTemplate>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="FocusStates">
                <VisualState x:Name="Unfocused"/> <!--leave the unfocused state empty if the control already looks "unfocused" -->
                <VisualState x:Name="Focused">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="background" Storyboard.TargetProperty="Opacity" To="0.2" Duration="0"/>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Border x:Name="background" Background="Red" Opacity="0" />
        <!--other stuff-->
    </ControlTemplate>
</Combobox.Template>

Combobox控件根据鼠标/键盘输入自动切换其内置状态,如聚焦、按下、鼠标悬停等。通过切换状态,为当前状态定义的情节提要将被反转,为新状态定义的情节提要将被应用。您可以在此处查看可用状态:


(使用代码隐藏,您也可以基于事件等实现自己的状态,但这应该很少需要。)

检查我知道没有标准控件。我的问题是关于实现这种效果。通过在c#中使用GotFocus和LostFocus事件,我可以实现类似的效果,但我想使用VisualStates修改组合框模板。我怎么做?非常感谢。