【问题标题】:How do use a static value in a value list XAML?如何在值列表 XAML 中使用静态值?
【发布时间】:2020-09-21 14:35:54
【问题描述】:

假设我有一个<Grid/>,并且我正在对其设置Margin 属性。我想在我设置的值列表中引用单个静态值。例如:

<Grid Margin="1,22,3,7"/>

我想做这样的事情:

<Grid Margin="1,{x:Static SystemParameters.CaptionHeight},3,7"/>

我知道这是错误的语法,但我想做类似的事情。有可能吗?

【问题讨论】:

    标签: .net wpf xaml


    【解决方案1】:

    是的,您可以这样做。只需在详细语法中声明边距值:

    <Grid>
      <Grid.Margin>
        <Thickness Left="1" Top="{x:Static SystemParameters.CaptionHeight}" Bottom="3" Right="7"/>
      </Grid.Margin>
    </Grid>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多