首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > CAD教程 >

* 视觉状态控制:为什么小弟我的控件无法显示

2012-02-10 
***求助*** 视觉状态控制:为什么我的控件无法显示我是新手,高手帮忙啊,下面是我的代码,不知道我的checkbox

***求助*** 视觉状态控制:为什么我的控件无法显示
我是新手,高手帮忙啊,下面是我的代码,不知道我的checkbox 为什么显示不出来啊。

App.xaml 视觉控制 checkbox
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  x:Class="SilverlightApplicationTest01.App"
  xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
  >
  <Application.Resources>
  <ControlTemplate x:Key="myCheckBoxControlTemplate" TargetType="CheckBox">
  <Grid>
  <vsm:VisualStateManager.VisualStateGroups>
  <!-- CommonStates Group -->
  <vsm:VisualStateGroup x:Name="CommonStates">

  <!-- CommonState StateGroup -->
  <vsm:VisualState x:Name="Normal">
  </vsm:VisualState>
  <!-- MouseOver State -->
  <vsm:VisualState x:Name="MouseOver">
  <Storyboard>
  <DoubleAnimation 
  Storyboard.TargetName="Glow" 
  Storyboard.TargetProperty="Opacity" 
  Duration="0" To="1" />
  </Storyboard>
  </vsm:VisualState>
  <!-- Pressed State -->
  <vsm:VisualState x:Name="Pressed">
  <Storyboard>
  <DoubleAnimation Storyboard.TargetName="HighlightBorder" 
  Storyboard.TargetProperty="Opacity" 
  Duration="0" To=".6" />
  <ColorAnimation Storyboard.TargetName="InnerBorder"
  Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[0].(GradientStop.Color)"
  Duration="0" To="#FF000000" />
  <ColorAnimation Storyboard.TargetName="InnerBorder" 
  Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[1].(GradientStop.Color)"
  Duration="0" To="#FF000000" />
  </Storyboard>
  </vsm:VisualState>
  <!-- Disabled State -->
  <vsm:VisualState x:Name="Disabled">
  <Storyboard>
  <DoubleAnimation 
  Storyboard.TargetName="Root"
  Storyboard.TargetProperty="Opacity"
  Duration="0" To=".5" />
  </Storyboard>
  </vsm:VisualState>
   
  <!-- CommonStates Transitions -->
  <vsm:VisualStateGroup.Transitions>


  <vsm:VisualTransition GeneratedDuration="0:0:.5" />
  <vsm:VisualTransition GeneratedDuration="0:0:.8" To="MouseOver" />
  <vsm:VisualTransition GeneratedDuration="0:0:.2" From="Pressed"/>
  <vsm:VisualTransition GeneratedDuration="0" From="MouseOver" To="Pressed"/>
  </vsm:VisualStateGroup.Transitions>

  </vsm:VisualStateGroup>

  <!-- CheckStates Group -->
  <vsm:VisualStateGroup x:Name="CheckStates">
  <!-- Unchecked State -->
  <vsm:VisualState x:Name="Unchecked" />
  <!-- Checked State -->
  <vsm:VisualState x:Name="Checked">
  <Storyboard>
  <DoubleAnimation 
  Storyboard.TargetName="Checkmark"
  Storyboard.TargetProperty="Opacity"
  Duration="0" To="1"/>
  </Storyboard>
  </vsm:VisualState>
  <!-- Indeterminate State -->
  <vsm:VisualState x:Name="Indeterminate">
  <Storyboard>
  <DoubleAnimation 
  Storyboard.TargetName="IndeterminateRect"
  Storyboard.TargetProperty="Opacity"
  Duration="0" To="1"/>
  </Storyboard>
  </vsm:VisualState>

  <!-- CheckStates Transitions -->
  <vsm:VisualStateGroup.Transitions>
  <vsm:VisualTransition GeneratedDuration="0:0:.2" />
  </vsm:VisualStateGroup.Transitions>
  </vsm:VisualStateGroup>

  </vsm:VisualStateManager.VisualStateGroups>

   


  <StackPanel x:Name="Root">
  <Border x:Name="OuterBorder" Width="50" Height="50">
  <Border x:Name="InnerBorder">
  <Grid>
  <Border x:Name="HighlightBorder"></Border>
  <Rectangle x:Name="Glow" Opacity="0"></Rectangle>
  <Path x:Name="Checkmark" Opacity="0"></Path>
  <Rectangle x:Name="IndeterminateRect" Opacity="0"></Rectangle>
  </Grid>
  </Border>
  </Border>
  <ContentPresenter />
  </StackPanel>
  </Grid>
  </ControlTemplate>
   
   


  </Application.Resources>
</Application>

Page.xmal

<UserControl x:Class="SilverlightApplicationTest01.Page"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  Width="400" Height="300">
  <Canvas Background="White">
  <CheckBox x:Name="myCheckBox" Canvas.Left="40" Canvas.Top="50" Template="{StaticResource myCheckBoxControlTemplate}" />
  </Canvas>
</UserControl>

错误在哪呢, 十分不明白,silverlight上来就给我个下马威,脑子不够用了,高手帮忙啊。


[解决办法]

XML code
<CheckBox x:Name="myCheckBox" Canvas.Left="40" Canvas.Top="50" Template="{StaticResource myCheckBoxControlTemplate}" /> 

热点排行