在WPF中指定宽度/高度作为资源

时间:2010-02-17 10:07:38

标签: wpf resources styles resourcedictionary

WPF中是否有一种方法可以指定宽度/高度作为资源,以便可以在多种样式中重复使用,例如余量/填充?

1 个答案:

答案 0 :(得分:47)

不确定

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:sys="clr-namespace:System;assembly=mscorlib"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Page.Resources>
    <sys:Double x:Key="Height">200</sys:Double>
    <sys:Double x:Key="Width">200</sys:Double>
  </Page.Resources>
  <Grid>  
    <Rectangle 
      Height="{StaticResource Height}" 
      Width="{StaticResource Width}" 
      Fill="Blue"/>
  </Grid>
</Page>
相关问题