当我将GridSplitter向左拖动时,下面的XAML会将元素推出窗口.如何将所有元素保留在窗口框架内?
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="0" />
<Button Grid.Column="1" Content="1" />
<Button Grid.Column="2" Content="2" />
<GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Left" />
</Grid>
Run Code Online (Sandbox Code Playgroud)
谢谢
所有这些魔法让我有点不清楚.据我所知,依赖属性从DependencyObject继承,因此存储了值:
如果未指定值,则从链接获取父元素.
protected object GetValue(string propertyName)
{
if (LocalValues.ContainsKey(propertyName))
{
return LocalValues[propertyName];
}
return Parent.GetValue(propertyName);
}
Run Code Online (Sandbox Code Playgroud)
我这是对的吗?
我也不明白附加属性的值存储在哪里?
Control.FontSizeProperty = TextElement.FontSizeProperty.AddOwner(
typeof(Control), new FrameworkPropertyMetadata(SystemFonts.MessageFontSize,
FrameworkPropertyMetadataOptions.Inherits));
Run Code Online (Sandbox Code Playgroud)
Addached属性上的AddOwner方法调用是否为实例字段赋值?什么时候发生这种情况,价值在哪里?
谢谢!