Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Silverlight:更改状态的样式_Silverlight_Xaml_Silverlight 4.0 - Fatal编程技术网

Silverlight:更改状态的样式

Silverlight:更改状态的样式,silverlight,xaml,silverlight-4.0,Silverlight,Xaml,Silverlight 4.0,我的App.xaml如下所示: <Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="mySilverlightApp.App" > <Application.Resources>

我的App.xaml如下所示:

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
         x:Class="mySilverlightApp.App"
         >
<Application.Resources>
    <Style x:Name="ComboBoxStyle" TargetType="ComboBox">
        <Setter Property="FontFamily"  Value="Calibri.ttf#Calibri"></Setter>
    </Style>
</Application.Resources>

如您所见,我正在尝试将带有
标记的自定义样式应用于我的应用程序中的组合框。但是我想为组合框的不同状态应用样式(鼠标悬停等)


如何才能做到这一点?

要做到这一点,您必须以隐式样式创建一个控件模板。如下所示:

<Style x:Name="ComboBoxStyle" TargetType="ComboBox">
    <Setter Property="Template">
         <Setter.Value>
              <ControlTemplate TargetType="ComboBox">
                  ....
              </ControlTemplate>
         </Setter.Value>
    </Setter>
</Style>

....
您可以参考此链接了解组合框的默认样式/控制模板:

开始重新模板化控件的一个好方法是使用Blend。您可以右键单击拖动到艺术板上的控件,并使用“编辑模板->编辑副本”命令。这将为您创建一个默认的controltemplate(与我提供的链接中显示的相同)

从那里,您可以使用“状态”选项卡在混合中编辑鼠标悬停状态

这里发生了很多事情,但这会让你走上正确的道路