首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >wpf,Style,Setters

wpf,Style,Setters
EN

Stack Overflow用户
提问于 2010-04-16 20:56:22
回答 1查看 1.2K关注 0票数 1

我对wpf xaml样式定义有疑问。当我尝试以这种方式设置样式时:

代码语言:javascript
复制
<StackPanel Orientation="Vertical">
      <StackPanel.Style>
          <Setter Property="BusinessModeler:GraphItemBehaviour.IsBroughtIntoViewWhenSelected" Value="True" />
      </StackPanel.Style>
</StackPanel>

使用message - 'System.Windows.Setter' is not a valid value for property 'Style'引发异常。

当我使用这个定义时:

代码语言:javascript
复制
<Style x:Key="itemBehaviour" > 
    <Setter Property="BusinessModeler:GraphItemBehaviour.IsBroughtIntoViewWhenSelected" Value="True" />
</Style>
<StackPanel Orientation="Vertical" Style="{StaticResource itemBehaviour}">

一切都很好。

那么,有什么不同呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-04-16 21:06:03

StackPanel.Style是一个Style类型的属性,因此在不将Setter包装在<Style></Style>中的情况下,您可以尝试将Style属性设置为Setter类型的内容。

代码语言:javascript
复制
<StackPanel.Style>
    <Style>
        <Setter Property="BusinessModeler:GraphItemBehaviour.IsBroughtIntoViewWhenSelected" Value="True" />
    </Style>
</StackPanel.Style> 
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2653061

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档