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


C# FrameworkElement.GetType方法代码示例

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


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

示例1: GetExtraPropertyInfo

        private void GetExtraPropertyInfo(FrameworkElement frameworkElement, out object extraPropertyValue, out TypeInfo extraPropertyType)
        {
            extraPropertyValue = null;
            extraPropertyType = null;

            if (ExtraArgumentPropertyName != null)
            {
                var extraPropertyInfo = frameworkElement.GetType().GetRuntimeProperty(ExtraArgumentPropertyName);
                if (extraPropertyInfo == null)
                    Debug.WriteLine(string.Format("Cannot find property {0} on UI element {1} when handling event {2}", ExtraArgumentPropertyName, frameworkElement.GetType().FullName, EventName));
                else
                {
                    extraPropertyValue = extraPropertyInfo.GetValue(frameworkElement);
                    if (extraPropertyValue != null)
                        extraPropertyType = extraPropertyValue.GetType().GetTypeInfo();
                }
            }
        }
开发者ID:aaronpowell,项目名称:Bob,代码行数:18,代码来源:EventToDataContextMethod.cs

示例2: ApplyBindings

 protected override void ApplyBindings(FrameworkElement attachedObject,
                                       IEnumerable<MvxBindingDescription> bindingDescriptions)
 {
     var actualType = attachedObject.GetType();
     foreach (var bindingDescription in bindingDescriptions)
     {
         ApplyBinding(bindingDescription, actualType, attachedObject);
     }
 }
开发者ID:MvvmCross,项目名称:MvvmCross,代码行数:9,代码来源:MvxWindowsBindingCreator.cs

示例3: Appear

        public static void Appear(FrameworkElement el, int millisecondPostpone = 0)
        {
            if (el.GetType().Name == "SplashScreenView")
            {
                el.Opacity =1.0;
                return;
            }


            DispatchedHandler invokedHandler = new DispatchedHandler(() =>
            {
                TranslateTransform translateTransform = new TranslateTransform();
                el.RenderTransform = translateTransform;
                translateTransform.X = (double)Animation.pixelsMove;
                if (translateTransform != null)
                {
                    SplineDoubleKeyFrame splineDoubleKeyFrame = new SplineDoubleKeyFrame();
                    splineDoubleKeyFrame.KeyTime = TimeSpan.FromMilliseconds((double)(10 + millisecondPostpone));
                    splineDoubleKeyFrame.Value = (double)Animation.pixelsMove;
                    SplineDoubleKeyFrame splineDoubleKeyFrame2 = new SplineDoubleKeyFrame();
                    splineDoubleKeyFrame2.KeyTime = TimeSpan.FromMilliseconds((double)(350 + millisecondPostpone));
                    splineDoubleKeyFrame2.Value = 0.0;
                    splineDoubleKeyFrame2.KeySpline = new KeySpline();
                    splineDoubleKeyFrame2.KeySpline.ControlPoint1 = new Point(0.0, 0.0);
                    splineDoubleKeyFrame2.KeySpline.ControlPoint2 = new Point(0.0, 1.0);
                    DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
                    Storyboard.SetTarget(doubleAnimationUsingKeyFrames, translateTransform);
                    Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrames, "(TranslateTransform.X)");
                    doubleAnimationUsingKeyFrames.KeyFrames.Add(splineDoubleKeyFrame);
                    doubleAnimationUsingKeyFrames.KeyFrames.Add(splineDoubleKeyFrame2);
                    SplineDoubleKeyFrame splineDoubleKeyFrame3 = new SplineDoubleKeyFrame();
                    splineDoubleKeyFrame3.KeyTime = TimeSpan.FromMilliseconds((double)millisecondPostpone);
                    splineDoubleKeyFrame3.Value = 0.0;
                    SplineDoubleKeyFrame splineDoubleKeyFrame4 = new SplineDoubleKeyFrame();
                    splineDoubleKeyFrame4.KeyTime = TimeSpan.FromMilliseconds((double)(300 + millisecondPostpone));
                    splineDoubleKeyFrame4.Value = 1.0;
                    DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames2 = new DoubleAnimationUsingKeyFrames();
                    Storyboard.SetTarget(doubleAnimationUsingKeyFrames2, el);
                    Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrames2, "(UIElement.Opacity)");
                    doubleAnimationUsingKeyFrames2.KeyFrames.Add(splineDoubleKeyFrame3);
                    doubleAnimationUsingKeyFrames2.KeyFrames.Add(splineDoubleKeyFrame4);
                    Storyboard storyboard = new Storyboard();
                    storyboard.Children.Add(doubleAnimationUsingKeyFrames);
                    storyboard.Children.Add(doubleAnimationUsingKeyFrames2);
                    storyboard.Begin();
                }

            });


            el.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, invokedHandler).GetResults();
        }
开发者ID:liquidboy,项目名称:X,代码行数:52,代码来源:Animation.cs

示例4: Attach

 /// <summary>
 /// Attaches to the specified object.
 /// 
 /// </summary>
 /// <param name="dependencyObject">The object to attach to.</param><exception cref="T:System.InvalidOperationException">The Behavior is already hosted on a different element.</exception><exception cref="T:System.InvalidOperationException">dependencyObject does not satisfy the Behavior type constraint.</exception>
 public override void Attach(FrameworkElement dependencyObject)
 {
     if (dependencyObject == this.AssociatedObject)
     {
         return;
     }
     if (this.AssociatedObject != null)
     {
         throw new InvalidOperationException("Cannot host behavior multiple times.");
     }
     if (dependencyObject != null && !this.AssociatedObjectTypeConstraint.GetTypeInfo().IsAssignableFrom(dependencyObject.GetType().GetTypeInfo()))
     {
         throw new InvalidOperationException("Type constraint violated.");
     }
     else
     {
         this.AssociatedObject = dependencyObject;
         this.OnAssociatedObjectChanged();
         //we need to fix the datacontext for databinding to work
         this.ConfigureDataContext();
         this.OnAttached();
     }
 }
开发者ID:LoungeFlyZ,项目名称:Caliburn-Micro-WinRT-Callisto-Helpers,代码行数:28,代码来源:Behavior.cs

示例5: Attach

 /// <summary>
 /// Attaches to the specified object.
 /// 
 /// </summary>
 /// <param name="frameworkElement">The object to attach to.</param><exception cref="T:System.InvalidOperationException">The Behavior is already hosted on a different element.</exception><exception cref="T:System.InvalidOperationException">dependencyObject does not satisfy the Behavior type constraint.</exception>
 public override void Attach(FrameworkElement frameworkElement)
 {
     if (frameworkElement == this.AssociatedObject)
     {
         return;
     }
     if (this.AssociatedObject != null)
     {
         throw new InvalidOperationException("Cannot host behavior multiple times.");
     }
     if (frameworkElement != null && !this.AssociatedObjectTypeConstraint.GetTypeInfo().IsAssignableFrom(frameworkElement.GetType().GetTypeInfo()))
     {
         throw new InvalidOperationException("Type constraint violated.");
     }
     else
     {
         this.AssociatedObject = frameworkElement;
         this.OnAssociatedObjectChanged();
         //Attach handles the DataContext
         base.Attach(frameworkElement);                
         this.OnAttached();
     }
 }
开发者ID:MikhasyovaDiana,项目名称:Windows.UI.Interactivity,代码行数:28,代码来源:Behavior.cs

示例6: Attach

 /// <summary>
 /// Attaches to the specified object.
 /// 
 /// </summary>
 /// <param name="frameworkElement">The object to attach to.</param><exception cref="T:System.InvalidOperationException">Cannot host the same trigger on more than one object at a time.</exception><exception cref="T:System.InvalidOperationException">dependencyObject does not satisfy the trigger type constraint.</exception>
 public override async void Attach(FrameworkElement frameworkElement)
 {
     if (frameworkElement == this.AssociatedObject)
     {
         return;
     }
     if (this.AssociatedObject != null)
     {
         throw new InvalidOperationException("Cannot Host Trigger Multiple Times");
     }
     if (frameworkElement != null && !this.AssociatedObjectTypeConstraint.GetTypeInfo().IsAssignableFrom(frameworkElement.GetType().GetTypeInfo()))
     {
         throw new InvalidOperationException("Type Constraint Violated");
     }
     else
     {
         this.AssociatedObject = frameworkElement;                
         this.OnAssociatedObjectChanged();
         //we need to fix the datacontext for databinding to work
         await this.ConfigureDataContext();
         this.Actions.Attach(frameworkElement);
         this.OnAttached();
     }
 }
开发者ID:AmrReda,项目名称:Windows.UI.Interactivity,代码行数:29,代码来源:TriggerBase.cs

示例7: ContentDialogWrapper

            public ContentDialogWrapper(FrameworkElement window)
            {
                _window = window;
                if (_closingEvent == null)
                    _closingEvent = window.GetType().GetRuntimeEvent("Closing");

                Delegate handler = ServiceProvider
                    .ReflectionManager
                    .TryCreateDelegate(_closingEvent.EventHandlerType, this, OnClosingMethod);
                if (handler == null)
                {
                    Tracer.Error("The provider cannot create delegate for event '{0}'", _closingEvent.EventHandlerType);
                    return;
                }
                _token = (EventRegistrationToken)_closingEvent.AddMethod.InvokeEx(window, handler);
            }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:16,代码来源:PlatformWrapperRegistrationModule.cs

示例8: ApplyBinding

        /// <summary>
        /// Applies the Binding represented by the SetterValueBindingHelper.
        /// </summary>
        /// <param name="element">Element to apply the Binding to.</param>
        /// <param name="item">SetterValueBindingHelper representing the Binding.</param>
        private static void ApplyBinding(FrameworkElement element, SetterValueBindingHelper item)
        {
            if ((null == item.Property) || (null == item.Binding))
            {
                throw new ArgumentException(
                    "SetterValueBindingHelper's Property and Binding must both be set to non-null values.");
            }

            // Get the type on which to set the Binding
            Type type = null;
            TypeInfo typeInfo = null;
            if (null == item.Type)
            {
                // No type specified; setting for the specified element
                type = element.GetType();
                typeInfo = type.GetTypeInfo();
            }
            else
            {
                // Try to get the type from the type system
                type = System.Type.GetType(item.Type);
                if (null == type)
                {
                    // Search for the type in the list of assemblies
                    foreach (var assembly in AssembliesToSearch)
                    {
                        // Match on short or full name
                        typeInfo = assembly.DefinedTypes
                            .Where(t => (t.FullName == item.Type) || (t.Name == item.Type))
                            .FirstOrDefault();
                        if (null != typeInfo)
                        {
                            // Found; done searching
                            break;
                        }
                    }
                    if (null == typeInfo)
                    {
                        // Unable to find the requested type anywhere
                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
                                                                  "Unable to access type \"{0}\". Try using an assembly qualified type name.",
                                                                  item.Type));
                    }
                }
                else
                {
                    typeInfo = type.GetTypeInfo();
                }
            }

            // Get the DependencyProperty for which to set the Binding
            DependencyProperty property = null;
            var field = typeInfo.GetDeclaredProperty(item.Property + "Property"); // type.GetRuntimeField(item.Property + "Property");
            if (null != field)
            {
                property = field.GetValue(null) as DependencyProperty;
            }
            if (null == property)
            {
                // Unable to find the requsted property
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
                                                          "Unable to access DependencyProperty \"{0}\" on type \"{1}\".",
                                                          item.Property, type.Name));
            }

            // Set the specified Binding on the specified property
            element.SetBinding(property, item.Binding);
        }
开发者ID:rmarinho,项目名称:babysmash,代码行数:73,代码来源:SetterValueBindingHelper.cs

示例9: GetViewModelForView

        // </snippet3303>
        // </snippet300>

        private static object GetViewModelForView(FrameworkElement view)
        {
            // Mapping of view models base on view type (or instance) goes here
            if (factories.ContainsKey(view.GetType().ToString()))
                return factories[view.GetType().ToString()]();
            return null;
        }
开发者ID:stevenh77,项目名称:ItineraryHunter-Win8,代码行数:10,代码来源:ViewModelLocator.cs

示例10: ToggleVisibility

        /// <summary>
        /// This method will change the visibility of the framework element that is passed as an argument, to collapsed.
        /// It will then use the siblingType parameter to find the other element that should be toggled to visible
        /// </summary>
        /// <param name="caller">FrameworkElement that should be collapsed</param>
        /// <param name="siblingType">The type of the sibling that should be visible</param>
        // This was originally ment for an inferiour solution, with no usercontrol.
        // However, i like the solution i made, so im going to keep this.
        private void ToggleVisibility(FrameworkElement caller, Type siblingType)
        {
            var sibling = caller?
                                .FindName(
                                          caller
                                          .Name?
                                          .Replace(
                                                   caller
                                                   .GetType()
                                                   .Name
                                                   .ToLower(),

                                                   siblingType
                                                   .Name
                                                   .ToLower()
                                                   )
                                          ) as FrameworkElement;

            if (sibling == null) return; // TODO implement some kind of error handeling/notification.

            caller.Visibility = Visibility.Collapsed;
            sibling.Visibility = Visibility.Visible;
        }
开发者ID:Toudahl,项目名称:SoftwareDesignHelper,代码行数:31,代码来源:DisplayAndEditControl.xaml.cs


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