小编elm*_*elm的帖子

有没有办法让GridSplitter不要将元素推出窗口?

当我将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)

谢谢

wpf grid gridsplitter

7
推荐指数
1
解决办法
3196
查看次数

依赖/附加属性如何在内部工作以及值存储在何处?

所有这些魔法让我有点不清楚.据我所知,依赖属性从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方法调用是否为实例字段赋值?什么时候发生这种情况,价值在哪里?

谢谢!

wpf dependency-properties attached-properties

6
推荐指数
1
解决办法
1067
查看次数