Visual Studio Ultimate 2012 RC win8 Metro应用的一个小bug-样式继承
2012-06-27 11:49
483 查看
偶然发现Visual Studio Ultimate 2012 RC的一个小bug。
MSDN上的Using based-on styles示例
http://msdn.microsoft.com/en-US/library/windows/apps/xaml/hh465381
该段代码在 Visual Studio Ultimate 2012 RC 中会报错:Can only base on a Style with target type that is base type of this style's target type.
但实际是可以运行的。
因为Button和CheckBox都继承自ButtonBase,于是我把第二行代码改为<Style x:Key="BasicStyle" TargetType="ButtonBase">,这样就不报错了,同样也能运行。
毕竟是RC版,使用的时候还有一些其它问题,正式版应该会好很多。
MSDN上的Using based-on styles示例
http://msdn.microsoft.com/en-US/library/windows/apps/xaml/hh465381
<Page.Resources> <Style x:Key="BasicStyle" TargetType="ContentControl"> <Setter Property="Width" Value="100" /> <Setter Property="Height" Value="30" /> </Style> <Style x:Key="ButtonStyle" TargetType="Button" BasedOn="{StaticResource BasicStyle}"> <Setter Property="BorderBrush" Value="Orange" /> <Setter Property="BorderThickness" Value="2" /> <Setter Property="Foreground" Value="Orange" /> </Style> <Style x:Key="CheckBoxStyle" TargetType="CheckBox" BasedOn="{StaticResource BasicStyle}"> <Setter Property="BorderBrush" Value="Green" /> <Setter Property="BorderThickness" Value="2" /> <Setter Property="Foreground" Value="Green" /> </Style> </Page.Resources> <Grid Background="White"> <Button Content="Button" Style="{StaticResource ButtonStyle}"/> <CheckBox Content="CheckBox" Style="{StaticResource CheckBoxStyle}"/> </Grid>
该段代码在 Visual Studio Ultimate 2012 RC 中会报错:Can only base on a Style with target type that is base type of this style's target type.
但实际是可以运行的。
因为Button和CheckBox都继承自ButtonBase,于是我把第二行代码改为<Style x:Key="BasicStyle" TargetType="ButtonBase">,这样就不报错了,同样也能运行。
毕竟是RC版,使用的时候还有一些其它问题,正式版应该会好很多。
相关文章推荐
- Microsoft Visual Studio Ultimate 2012 旗舰版 密钥
- Visual Studio Ultimate 2012 静态激活密钥
- Visual Studio Ultimate 2012 静态激活密钥
- Visual Studio Ultimate 2012 静态激活密钥
- Visual Studio Ultimate 2012 RC 安装手记
- Visual Studio Ultimate 2012: 使用 Code Map 理解复杂代码
- Visual Studio Ultimate 2012 产品密钥
- Visual Studio Ultimate 2012 静态激活密钥
- Visual Studio Ultimate 2012 静态激活密钥
- Visual Studio Ultimate 2012 RC 安装手记
- Blend for Visual Studio 2012:为Windows 8应用所用的UX工具
- Visual Studio Ultimate 2012 静态激活密钥
- 将Visual Studio Ultimate 2012 RC语言设置从中文换成英文
- Microsoft Visual Studio Ultimate 2012 ISO 映像
- Microsoft Visual Studio Ultimate 2012 旗舰版 有效注册密钥
- Visual Studio Ultimate 2012 激活密钥
- Visual Studio Ultimate 2012 静态激活密钥
- 使用visual studio ultimate 2013进行UI测试------在C#课程写的应用:数码宝贝第一部简介
- Microsoft .net framework required for microsoft visual studio ultimate 2012 setup解决办法
- How to build python3.3 using Visual Studio 2012 Ultimate