Beispiel #1
0
        private static object GetDefaultAnchor(ITypeDescriptorContext context)
        {
            // If the target is not a control, so we need to find an anchor that will let us look
            // up named controls and style resources. First look for the closest IControl in
            // the context.
            object anchor = context.GetFirstAmbientValue <IControl>();

            // If a control was not found, then try to find the highest-level style as the XAML
            // file could be a XAML file containing only styles.
            return(anchor ??
                   context.GetService <IRootObjectProvider>()?.RootObject as IStyle ??
                   context.GetLastOrDefaultAmbientValue <IStyle>());
        }