当前位置: 首页>>代码示例>>C#>>正文


C# FrameworkElement.GetType方法代码示例

本文整理汇总了C#中System.Windows.FrameworkElement.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElement.GetType方法的具体用法?C# FrameworkElement.GetType怎么用?C# FrameworkElement.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.FrameworkElement的用法示例。


在下文中一共展示了FrameworkElement.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDataContextSubscriptionMode

        private static DataContextSubscriptionMode GetDataContextSubscriptionMode(FrameworkElement element)
        {
            var dependencyResolver = IoCConfiguration.DefaultDependencyResolver;
            var dataContextSubscriptionService = dependencyResolver.Resolve<IDataContextSubscriptionService>();

            return dataContextSubscriptionService.GetDataContextSubscriptionMode(element.GetType());
        }
开发者ID:jensweller,项目名称:Catel,代码行数:7,代码来源:DataContextChangedHelper.cs

示例2: FrameworkElementWrapper

 public FrameworkElementWrapper(FrameworkElement element, HereString hereString, FrameworkElementWrapper parent = null)
 {
     Element = element;
     XamlDeclaration = hereString;
     Icon = IconMappings.ContainsKey(element.GetType().Name)
         ? IconMappings[element.GetType().Name]
         : IconMappings["Element"];
     GenerateChildren();
     Parent = parent;
     EventMappings = new Dictionary<string, PsEventHandler>();
     var events = element.GetType().GetEvents();
     foreach (var eventInfo in events)
     {
         EventMappings.Add(eventInfo.Name, null);
     }
 }
开发者ID:DavidSeptimus,项目名称:PowerShell-DAVToolkit,代码行数:16,代码来源:FrameworkElementWrapper.cs

示例3: CopyValues

 internal void CopyValues( FrameworkElement element )
 {
     foreach( PropertyInfo prop in element.GetType().GetProperties() )
     {
         _originalValues.Add( prop.Name, prop.GetValue( element, null ) );
     }
 }
开发者ID:dingxinbei,项目名称:OLdBck,代码行数:7,代码来源:PropertyValuesSnapshot.cs

示例4: GenerateTypePath

        public static List<TypeIndexAssociation> GenerateTypePath(FrameworkElement element)
        {
            List<TypeIndexAssociation> typePath = new List<TypeIndexAssociation>();
            while (element != null)
            {
                int index = 0;

                if (VisualTreeHelper.GetParent(element) != null)
                {
                    DependencyObject parent = VisualTreeHelper.GetParent(element);

                    if (parent is Panel)
                    {
                        index = ((Panel)parent).Children.IndexOf(element);
                    }
                }

                typePath.Add(new TypeIndexAssociation() { ElementType = element.GetType(), Index = index });

                element = VisualTreeHelper.GetParent(element) as FrameworkElement;
            }

            typePath.Reverse();
            return typePath;
        }
开发者ID:nfriend,项目名称:TutorialOverlay,代码行数:25,代码来源:ClickyRecordingWindow.xaml.cs

示例5: FindMissionUserControls

        private void FindMissionUserControls(FrameworkElement frameworkElement, List<MissionUserControl> missionUserControls)
        {
            if (frameworkElement.GetType().IsSubclassOf(typeof(MissionUserControl)) || frameworkElement.GetType() == typeof(MissionUserControl))
            {
                missionUserControls.Add((MissionUserControl)frameworkElement);
            }

            //go through children
            foreach (object logicalChild in LogicalTreeHelper.GetChildren(frameworkElement))
            {
                if (logicalChild.GetType().IsSubclassOf(typeof(FrameworkElement)))
                {
                    FindMissionUserControls((FrameworkElement)logicalChild, missionUserControls);
                }
            }
        }
开发者ID:vmendi,项目名称:AirbusMilitarySurface,代码行数:16,代码来源:MainWindow.xaml.cs

示例6: GetViewCloseAction

		private static Action GetViewCloseAction(object viewModel, FrameworkElement view, bool? dialogResult)
		{
			var viewType = view.GetType();
			var closeMethod = viewType.GetMethod("Close");

			if (closeMethod != null)
				return () =>
				{
					var isClosed = false;
					if (dialogResult != null)
					{
						var resultProperty = viewType.GetProperty("DialogResult");
						if (resultProperty != null)
						{
							resultProperty.SetValue(view, dialogResult, null);
							isClosed = true;
						}
					}

					if (!isClosed)
					{
						closeMethod.Invoke(view, null);
					}
				};

			return () => PiracRunner.GetLogger<Screen>().Info("TryClose requires a view with a Close method.");
		}
开发者ID:distantcam,项目名称:ServiceInsight2,代码行数:27,代码来源:Screen.cs

示例7: FindElementRecursive

 // 指定したタイプのUIElementを検索して返す
 public static UIElement FindElementRecursive(FrameworkElement parent, Type targetType)
 {
     if (parent.GetType() == targetType)
     {
         return parent as UIElement;
     }
     int childCount = VisualTreeHelper.GetChildrenCount(parent);
     UIElement returnElement = null;
     if (childCount > 0)
     {
         for (int i = 0; i < childCount; i++)
         {
             Object element = VisualTreeHelper.GetChild(parent, i);
             if (element.GetType() == targetType)
             {
                 return element as UIElement;
             }
             else
             {
                 returnElement = FindElementRecursive(VisualTreeHelper.GetChild(parent, i) as FrameworkElement, targetType);
             }
         }
     }
     return returnElement;
 }
开发者ID:KarinoTaro,项目名称:PullAndReleaseTest,代码行数:26,代码来源:ScrollViewerCompressionHelper.cs

示例8: ColorViewModel

 public ColorViewModel(FrameworkElement window)
 {
     Window = window;
     cmdShow = new RoutedCommand();
     CommandManager.RegisterClassCommandBinding(Window.GetType(), new CommandBinding(cmdShow, cmdShow_Click));
     FillColors();
 }
开发者ID:kovtunenkoa,项目名称:Colorer,代码行数:7,代码来源:ColorViewModel.cs

示例9: InitControlPrivider

        public static IOrientationProvider InitControlPrivider(FrameworkElement control)
        {
            if (control == null)
                return null;
            if (ProviderCollection.Providers.ContainsKey(control.GetType()))
            {
                IOrientationProvider provider = typeof(IOrientationProvider).Assembly.CreateInstance(ProviderCollection.Providers[control.GetType()]) as IOrientationProvider;

                return provider;
            }
            else
            {
                IOrientationProvider provider = new ElementOrientationProvider();//如果找不到对于的Provider 则使用默认元素Provider

                return provider;
            }
        }
开发者ID:SaintLoong,项目名称:PD,代码行数:17,代码来源:ManagerOrientationProvider.cs

示例10: __UIElementCollection

		public __UIElementCollection(FrameworkElement VisualParent)
		{
			var p = VisualParent as Panel;

			if (p == null)
				throw new Exception("VisualParent should be of type Panel instead of " + VisualParent.GetType().Name);


			this.InternalVisualParent = VisualParent;
		}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:10,代码来源:UIElementCollection.cs

示例11: WriteElementToXml

        private void WriteElementToXml(XmlWriter writer, FrameworkElement item)
        {
            if (item == null)
            {
                return;
            }

            writer.WriteStartElement(item.GetType().ToString());
            var coordinates = item.GetCoordinatesInView(this.Automator.VisualRoot);
            var rect = item.GetRect(this.Automator.VisualRoot);
            var attributes = new Dictionary<string, string>
                                 {
                                     { "name", item.AutomationName() },
                                     { "id", item.AutomationId() },
                                     { "xname", item.Name },
                                     {
                                         "visible",
                                         item.IsUserVisible(this.Automator.VisualRoot)
                                         .ToString()
                                         .ToLowerInvariant()
                                     },
                                     { "value", item.GetText() },
                                     { "x", rect.X.ToString(CultureInfo.InvariantCulture) },
                                     { "y", rect.Y.ToString(CultureInfo.InvariantCulture) },
                                     {
                                         "width",
                                         rect.Width.ToString(CultureInfo.InvariantCulture)
                                     },
                                     {
                                         "height",
                                         rect.Height.ToString(CultureInfo.InvariantCulture)
                                     },
                                     {
                                         "clickable_point",
                                         coordinates.ToString(CultureInfo.InvariantCulture)
                                     }
                                 };
            foreach (var attribute in attributes)
            {
                writer.WriteAttributeString(attribute.Key, attribute.Value);
            }

            var children = Finder.GetChildren(item);
            if (item == this.Automator.VisualRoot)
            {
                children = children.Concat(Finder.GetPopupsChildren());
            }

            foreach (var child in children)
            {
                this.WriteElementToXml(writer, child as FrameworkElement);
            }

            writer.WriteEndElement();
        }
开发者ID:2gis,项目名称:winphonedriver,代码行数:55,代码来源:PageSourceCommand.cs

示例12: AttachedBinding

        public AttachedBinding(DependencyObject target, FrameworkElement attachTarget,
            DependencyProperty bindingProperty, Type bindingType)
        {
            // basic checks
            if (target == null) throw new ArgumentNullException("target");
            if (attachTarget == null) throw new ArgumentNullException("attachTarget");
            if (bindingProperty == null) throw new ArgumentNullException("bindingProperty");
            if (bindingType == null) throw new ArgumentNullException("bindingType");

            // we save the reference to the source
            _target = new WeakReference(target);
            _attachTarget = new WeakReference(attachTarget);
            _bindingProperty = bindingProperty;

            // we get the default value
            object _defValue = bindingProperty.GetMetadata(bindingType).DefaultValue;

            // we attach the dp
            if (attachTarget != null)
            {
                // we create the attached property
                _attachedProperty = DependencyProperty.RegisterAttached(string.Format(DP_NAME_FROMAT, _indexer++),
                                                                        bindingType, attachTarget.GetType(),
                                                                        new PropertyMetadata(_defValue,
                                                                                             OnPropertyChanged));
            }
            else
            {
                attachTarget.Loaded += (s, e) =>
                                           {
                                               // we create the binding property
                                               _attachedProperty =
                                                   DependencyProperty.RegisterAttached(
                                                       string.Format(DP_NAME_FROMAT, _indexer++),
                                                       bindingType, attachTarget.GetType(),
                                                       new PropertyMetadata(_defValue, OnPropertyChanged));

                                               // and we if have binding then
                                               if (_binding != null) SetBinding(_binding);
                                           };
            }
        }
开发者ID:BGCX262,项目名称:zxd-svn-to-git,代码行数:42,代码来源:AttachedBinding.cs

示例13: Present

        public override void Present(FrameworkElement frameworkElement)
        {
            // this is really hacky - do it using attributes isnt
            var attribute = frameworkElement
                                .GetType()
                                .GetCustomAttributes(typeof (RegionAttribute), true)
                                .FirstOrDefault() as RegionAttribute;

            var regionName = attribute == null ? null : attribute.Name;
            _mainWindow.PresentInRegion(frameworkElement, regionName);
        }  
开发者ID:slodge,项目名称:BallControl,代码行数:11,代码来源:MultiRegionPresenter.cs

示例14: GetParentOfType

 // gets the first ancestor of an element that matches a given type
 public static object GetParentOfType(FrameworkElement e, Type type)
 {
     for (; e != null; e = VisualTreeHelper.GetParent(e) as FrameworkElement)
     {
         if (e.GetType().IsAssignableFrom(type))
         {
             return e;
         }
     }
     return null;
 }
开发者ID:mdjabirov,项目名称:C1Decompiled,代码行数:12,代码来源:Util.cs

示例15: RestoreValues

        internal void RestoreValues( FrameworkElement element )
        {
            foreach( PropertyInfo prop in element.GetType().GetProperties() )
            {
                object o = _originalValues[prop.Name];

                if( prop.CanWrite && o != prop.GetValue( element, null ) )
                {
                    prop.SetValue( element, o, null );
                }
            }
        }
开发者ID:dingxinbei,项目名称:OLdBck,代码行数:12,代码来源:PropertyValuesSnapshot.cs


注:本文中的System.Windows.FrameworkElement.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。