小编Bry*_*ell的帖子

容器如何知道孩子何时调用InvalidateArrange?

我正在尝试学习在WinRT XAML应用程序中创建自定义面板的基础知识.我已经定义了一个附加的依赖属性,它按预期工作,除了我无法弄清楚如何获取属性的子元素的回调来触发容器的排列或度量.

让孩子知道应该再次调用安排和测量的正确方法是什么?在我的WPF 4发行的书中,他们使用了FrameworkPropertyMetadataOptions.AffectsParentArrange,但在WinRT中似乎没有.

public class SimpleCanvas : Panel
{
    #region Variables
    #region Left Property
    public static double GetLeft(UIElement element)
    {
        if (element == null)
        {
            throw new ArgumentNullException("element");
        }

        object value = element.GetValue(LeftProperty);
        Type valueType = value.GetType();
        return Convert.ToDouble(value);
    } 

    public static void SetLeft(UIElement element, double value)
    {
        if (element == null)
        {
            throw new ArgumentNullException("element");
        }

        element.SetValue(LeftProperty, value);
    }

    public static readonly DependencyProperty LeftProperty =
        DependencyProperty.RegisterAttached("Left", typeof(double), typeof(SimpleCanvas),
        new PropertyMetadata(0, OnLeftPropertyChanged));

    public static void OnLeftPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) …
Run Code Online (Sandbox Code Playgroud)

c# xaml windows-runtime

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

标签 统计

c# ×1

windows-runtime ×1

xaml ×1