尝试应用于Button时,LocalResource显示为灰色。 [英] LocalResource is Greyed out when trying to apply to a Button.

查看:83
本文介绍了尝试应用于Button时,LocalResource显示为灰色。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计

 

我一直在关注"Microsoft Silverlight 4商业应用程序"一书中的指南,该部分也在:

http: //www.packtpub.com/article/understanding-expression-blend-how-to-use-silverlight-4

I've been following the guide in the book 'Microsoft Silverlight 4 Business Applications', the section is also at:
http://www.packtpub.com/article/understanding-expression-blend-how-to-use-silverlight-4

尝试申请时遇到麻烦对于按钮的smallTextStyle,styes下的'Local Resource'选项是灰色的,它让我感到难过。

Having trouble at the end there when trying to apply the smallerTextStyle to the button, the 'Local Resource' option under styes is greyed out and it has me stumped.

有人会知道我在这里做错了什么吗?在Blend和XAML中,这种风格显然存在于资源之下。手动编码也会产生异常,但异常也无济于事。

Would anyone have any idea what I might be doing wrong here? The style is clearly there under resources, in Blend and in the XAML. Coding it in manually draws exception also, but the exception doesn't help much.

问候

Ben

Regards
Ben

<UserControl x:Class="CakeNavigationButtons.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
  <UserControl.Resources>
    <Style TargetType="Button">
      <Setter Property="FontSize" Value="18.667"/>
      <Setter Property="Background" Value="Red"/>
      <Setter Property="FontWeight" Value="Bold"/>
      <Setter Property="FontStyle" Value="Italic"/>
      <Setter Property="Cursor" Value="Hand"/>
      <Setter Property="Margin" Value="5"/>
    </Style>
    <Style x:Key="smallerTextStyle" TargetType="UserControl">
    	<Setter Property="FontSize" Value="12"/>
    </Style>
  </UserControl.Resources>
	<UserControl.Style>
		<StaticResource ResourceKey="smallerTextStyle"/>
	</UserControl.Style>
  <Grid x:Name="LayoutRoot" Background="White">
    <StackPanel>
      <Button Content="Home" />
      <Button Content="Gallery" />
      <Button Content="Order"/>
      <Button Content="Locations"/>
      <Button Content="Contact Us"/>
      <Button Content="Franchise Opportunities"/>
    </StackPanel>
  </Grid>
</UserControl>

 

推荐答案

你好,

尝试这样的事情:

<UserControl.Resources>
		<System:Double x:Key="smallerTextSize">7</System:Double>
	</UserControl.Resources>

	<Grid x:Name="LayoutRoot" Background="White">
		<Button Content="Button" 
		HorizontalAlignment="Left" 
		Height="39" Margin="211,72,0,0" 
		VerticalAlignment="Top" 
		Width="74" FontSize="{StaticResource smallerTextSize}"/>
	</Grid>

您可以使用"高级选项"菜单(每个属性旁边的小方框)为任何属性创建本地资源,然后使用当选择按钮时,它再次将本地资源应用于FontSize属性。

You can use the Advanced Options menu (the little box next to each property) to create a Local Resource for any property and then use it again to apply the local resource to the FontSize property when the button is selected.

HTH

干杯


这篇关于尝试应用于Button时,LocalResource显示为灰色。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆