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中使用Setter.Value代替Setter_Silverlight_Xaml_Setter - Fatal编程技术网

在Silverlight中使用Setter.Value代替Setter

在Silverlight中使用Setter.Value代替Setter,silverlight,xaml,setter,Silverlight,Xaml,Setter,我知道我可以在Silverlight中编写一个Setter,如下所示: <Setter Property="Background" Value="{StaticResource MyBrush}" /> 但是,出于其他考虑,我必须以以下格式编写setter: <Setter Property="Background"> <Setter.Value> ????? static resource </Setter.Value>

我知道我可以在Silverlight中编写一个Setter,如下所示:

<Setter Property="Background" Value="{StaticResource MyBrush}" />

但是,出于其他考虑,我必须以以下格式编写setter:

<Setter Property="Background">
  <Setter.Value>
      ????? static resource
  </Setter.Value>
</Setter>

????? 静态资源
我看到的任何示例都将值设置为完整画笔,但我想使用现有资源,但我不知道如何编写它。这不仅仅是画笔,我在尝试找出正确类型的属性并设置其值时遇到了问题。有什么建议吗


Jeff

任何标记扩展,用{XXX}表示,都可以写成。这里,{StaticResource MyBrush}实际上正在创建StaticResourceExtension类型的对象,传递“MyBrush”作为其构造函数的唯一参数,构造函数本身设置对象的ResourceKey属性。您可以使用以下方法实现相同的效果:

<StaticResource ResourceKey="MyBrush" />


如果您不知道属性是什么类型,只需在感兴趣的属性上设置插入符号,然后按F1键在Visual Studio中打开帮助,该帮助将为您提供所需的信息。

这不起作用。我应该指定我使用的是Silverlight,而不是说XAML。看起来此构造在Silverlight中不可用。