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

有帮助吗?

解决方案

不确定

<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>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top