Tag: 实际

为什么在这种情况下ActualWidth和ActualHeight 0.0?

我在Canvas里面有一个Grid像这样定义: <Canvas x:Name="outerCanvas"> <Grid Grid.Row="1" Name="cGrid" ShowGridLines="True" Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource AncestorType={x:Type Canvas}}}" Height="{Binding Path=ActualHeight, RelativeSource={RelativeSource AncestorType={x:Type Canvas}}}"> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <Rectangle Name="rectangle1" Stroke="Black" Fill="AntiqueWhite" /> <Rectangle Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="1" Name="rectangle2" Stroke="Black" Fill="AliceBlue" /> <Rectangle Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1" Name="rectangle3" Stroke="Black" Fill="Aqua" /> <Rectangle Grid.Row="1" Grid.Column="0" […]

在WPF中的Width和ActualWidth有什么区别?

我目前正在使用WPF中的Panel ,我注意到,关于Width和Height属性,还有两个其他属性,称为ActualWidth和ActualHeight 。 ActualWidth 获取此元素的渲染宽度。 这是一个依赖属性。 (inheritance自FrameworkElement。) Width 获取或设置元素的宽度。 这是一个依赖属性。 (inheritance自FrameworkElement。) 参考: MSDN 任何人都可以指出两者之间的差异,以及何时使用两者之一?