• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FrameworkElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中FrameworkElement的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElement类的具体用法?C# FrameworkElement怎么用?C# FrameworkElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: FocusCore

		private static void FocusCore(FrameworkElement element)
		{
			//System.Diagnostics.Debug.WriteLine("Focusing element " + element.ToString());
			//System.Diagnostics.Debug.WriteLine(Environment.StackTrace);
			if (!element.Focus())
			{
				//System.Diagnostics.Debug.WriteLine("- Element could not be focused, invoking in dispatcher thread");
				element.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => element.Focus()));
			}

#if DEBUG
			// no good idea, seems to block sometimes
			int i = 0;
			while (i < 5)
			{
				if (element.IsFocused)
				{
					//if (i > 0)
					//    System.Diagnostics.Debug.WriteLine("- Element is focused now in round " + i + ", leaving");
					return;
				}
				Thread.Sleep(20);
				i++;
			}
			//if (i >= 5)
			//{
			//    System.Diagnostics.Debug.WriteLine("- Element is not focused after 500 ms, giving up");
			//}
#endif
		}
开发者ID:CADblokeWPFforks,项目名称:MultiSelectTreeView,代码行数:30,代码来源:FocusHelper.cs


示例2: UpdateImageSource

		public static void UpdateImageSource(FrameworkElement content, Grid hostBody, ImageSource imageSource, Stretch stretch)
		{
			if (hostBody == null || content == null)
				return;

			var imgRects = hostBody.Children.OfType<Rectangle>().ToArray();

			for (int i = imgRects.Count() - 1; i >= 0; i--)
			{
				hostBody.Children.Remove(imgRects[i]);
			}

			if (imageSource == null)
				return;

			var imgBrush = new ImageBrush { ImageSource = imageSource, Stretch = stretch };
			var imgRect = new Rectangle
			{
				OpacityMask = imgBrush
			};

			hostBody.Children.Add(imgRect);

			ApplyForegroundToFillBinding(content, imgRect);

			//var sb = new Storyboard();
			//ControlHelper.CreateDoubleAnimations(sb, imgBrush, "Opacity", 0.2, 1, 75);
			//hostBody.Dispatcher.BeginInvoke(sb.Begin);
		}
开发者ID:selaromdotnet,项目名称:Coding4FunToolkit,代码行数:29,代码来源:ButtonBaseHelper+(Windows+Phone).cs


示例3: ValidateTemplatedParent

 protected override void ValidateTemplatedParent(FrameworkElement templatedParent)
 {
     if (templatedParent == null)
         throw new ArgumentNullException("templatedParent");
     if (_TargetType != null && !_TargetType.IsInstanceOfType(templatedParent))
         throw new ArgumentException("Template target type mismatch.");
 }
开发者ID:Kation,项目名称:WebPresentation,代码行数:7,代码来源:ControlTemplate.cs


示例4: UnbindViewModelFromView

 /// <summary>
 /// Remove the ViewModel from the View's DataContext
 /// </summary>
 /// <param name="frameworkElement"></param>
 /// <param name="viewModel"></param>
 public void UnbindViewModelFromView(FrameworkElement frameworkElement, object viewModel)
 {
     if (frameworkElement.DataContext == viewModel)
     {
         frameworkElement.DataContext = null;
     }
 }
开发者ID:karolszmaj,项目名称:StyleMVVM,代码行数:12,代码来源:ViewModelDataContextBinder.cs


示例5: OnApplyTemplate

        /// <summary>
        /// Called when template should be applied to the control
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _elementHorizontalTemplateFrameworkElement = this.GetTemplateChild(PreviewControl.ElementHorizontalTemplateName) as FrameworkElement;
            _elementVerticalTemplateFrameworkElement = this.GetTemplateChild(PreviewControl.ElementVerticalTemplateName) as FrameworkElement;

            if (_currentGridResizeDirection == GridSplitter.GridResizeDirection.Columns)
            {
                if (_elementHorizontalTemplateFrameworkElement != null)
                {
                    _elementHorizontalTemplateFrameworkElement.Visibility = Visibility.Collapsed;
                }
                if (_elementVerticalTemplateFrameworkElement != null)
                {
                    _elementVerticalTemplateFrameworkElement.Visibility = Visibility.Visible;
                }
            }
            else
            {
                if (_elementHorizontalTemplateFrameworkElement != null)
                {
                    _elementHorizontalTemplateFrameworkElement.Visibility = Visibility.Visible;
                }
                if (_elementVerticalTemplateFrameworkElement != null)
                {
                    _elementVerticalTemplateFrameworkElement.Visibility = Visibility.Collapsed;
                }
            }
        }
开发者ID:dfr0,项目名称:moon,代码行数:33,代码来源:PreviewControl.cs


示例6: CheckArgument

 private static void CheckArgument(FrameworkElement element)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:LayoutInformation.cs


示例7: AddError

		internal static void AddError (FrameworkElement element, ValidationError error)
		{
			var errors = GetErrorsCore (element);
			errors.Add (error);
			if (errors.Count == 1)
				SetHasError (element, true);
		}
开发者ID:kangaroo,项目名称:moon,代码行数:7,代码来源:Validation.cs


示例8: CreateAnimation

        public override IEnumerable<Timeline> CreateAnimation(FrameworkElement element)
        {
            double startRotation = 0.0;
            double endRotation;

            if (StartRotation.HasValue)
                startRotation = StartRotation.Value;
            else
            {
                var compositeTransform = element.RenderTransform as CompositeTransform;
                if (compositeTransform != null)
                    startRotation = compositeTransform.Rotation;
            }
            if (EndRotation.HasValue)
                endRotation = EndRotation.Value;
            else
                endRotation = startRotation + 360.0;

            return new Timeline[]
            {
                element.AnimatePointProperty(AnimationProperty.RenderTransformOrigin)
                    .AddDiscreteKeyFrame(0.0, new Point(0.5, 0.5)),

                element.AnimateProperty(AnimationProperty.Rotation)
                    .AddEasingKeyFrame(0.0, startRotation)
                    .AddEasingKeyFrame(Duration, endRotation, Easing)
                    .AddDiscreteKeyFrame(Duration, startRotation),
            };
        }
开发者ID:uwper,项目名称:AnimationManager,代码行数:29,代码来源:RotateAnimations.cs


示例9: UnbindViewModelFromView

 /// <summary>
 /// if the view model implements the IParentDataContextAwareViewModel interface then the parents view will be disconnected.
 /// </summary>
 /// <param name="frameworkElement"></param>
 /// <param name="viewModel"></param>
 public void UnbindViewModelFromView(FrameworkElement frameworkElement, object viewModel)
 {
     if (viewModel is IParentDataContextAwareViewModel)
     {
         frameworkElement.Loaded -= InjectParentDataContextOnload;
     }
 }
开发者ID:karolszmaj,项目名称:StyleMVVM,代码行数:12,代码来源:ViewModelParentDataContextBinder.cs


示例10: CreateAnimation

        public override IEnumerable<Timeline> CreateAnimation(FrameworkElement element)
        {
            var transform = GetTransform(element);

            var list = new List<Timeline>
            {
                element.AnimateProperty(AnimationProperty.Opacity)
                    .AddEasingKeyFrame(0.0, 0)
                    .AddEasingKeyFrame(Duration, 1),
            };
            if (Math.Abs(DistanceX) > 0)
            {
                list.Add(
                    element.AnimateProperty(AnimationProperty.TranslateX)
                        .AddEasingKeyFrame(0.0, transform.TranslateX + DistanceX)
                        .AddEasingKeyFrame(Duration, transform.TranslateX, new CubicEase()));
            }
            if (Math.Abs(DistanceY) > 0)
            {
                list.Add(
                    element.AnimateProperty(AnimationProperty.TranslateY)
                        .AddEasingKeyFrame(0.0, transform.TranslateY + DistanceY)
                        .AddEasingKeyFrame(Duration, transform.TranslateY, new CubicEase()));
            }

            return list;
        }
开发者ID:uwper,项目名称:AnimationManager,代码行数:27,代码来源:FadeAnimations.cs


示例11: SetupEffect

    public virtual void SetupEffect(FrameworkElement parent, ref PositionColoredTextured[] verts, float zOrder, bool adaptVertsToBrushTexture)
    {
      if (!UpdateBounds(ref verts))
        return;
      float w = _vertsBounds.Width;
      float h = _vertsBounds.Height;
      float xoff = _vertsBounds.X;
      float yoff = _vertsBounds.Y;
      if (adaptVertsToBrushTexture)
        for (int i = 0; i < verts.Length; i++)
        {
          PositionColoredTextured vert = verts[i];
          float x = vert.X;
          float u = x - xoff;
          u /= w;

          float y = vert.Y;
          float v = y - yoff;
          v /= h;

          if (u < 0) u = 0;
          if (u > 1) u = 1;
          if (v < 0) v = 0;
          if (v > 1) v = 1;
          unchecked
          {
            Color4 color = ColorConverter.FromColor(Color.White);
            vert.Color = color.ToBgra();
          }
          vert.Tu1 = u;
          vert.Tv1 = v;
          vert.Z = zOrder;
          verts[i] = vert;
        }
    }
开发者ID:BigGranu,项目名称:MediaPortal-2,代码行数:35,代码来源:Effect.cs


示例12: Helper

			public Helper(FrameworkElement obj, DependencyProperty property, Action<object, object> changed, object currentValue)
			{
				this.obj = obj;
				this.property = property; 
				this.changed = changed;
				this.currentValue = currentValue;
			}
开发者ID:fstn,项目名称:WindowsPhoneApps,代码行数:7,代码来源:DependencyPropertyChangedEvent.cs


示例13: SkipToFill

 public void SkipToFill(FrameworkElement target)
 {
     if (Storyboard != null)
     {
         Storyboard.SkipToFill(target);
     }
 }
开发者ID:diab0l,项目名称:Granular,代码行数:7,代码来源:StoryboardAction.cs


示例14: UpdateClipSize

        public static void UpdateClipSize(FrameworkElement element, Size clipSize)
        {
            if (element != null)
            {
                RectangleGeometry clipRectangle = null;

                if (element.Clip == null)
                {
                    clipRectangle = new RectangleGeometry();
                    element.Clip = clipRectangle;
                }
                else
                {
                    if (element.Clip is RectangleGeometry)
                    {
                        clipRectangle = (RectangleGeometry)element.Clip;
                    }
                }

                if (clipRectangle != null)
                {
                    clipRectangle.Rect = new Rect(new Point(0, 0), clipSize);
                }
            }
        }
开发者ID:namlunoy,项目名称:benhvathuoc,代码行数:25,代码来源:ClipToBounds.cs


示例15: CreateAnimation

        public override IEnumerable<Timeline> CreateAnimation(FrameworkElement element)
        {
            var transform = GetTransform(element);

            return new Timeline[]
            {
                element.AnimatePointProperty(AnimationProperty.RenderTransformOrigin)
                    .AddDiscreteKeyFrame(0.0, new Point(0, 1)),

                element.AnimateProperty(AnimationProperty.Opacity)
                    .AddEasingKeyFrame(0.0, 0)
                    .AddEasingKeyFrame(Duration*0.6, 1),

                element.AnimateProperty(AnimationProperty.TranslateX)
                    .AddEasingKeyFrame(0.0, transform.TranslateX + 700)
                    .AddEasingKeyFrame(Duration*0.6, transform.TranslateX - 30, new QuadraticEase())
                    .AddEasingKeyFrame(Duration*0.8, transform.TranslateX),

                element.AnimateProperty(AnimationProperty.SkewX)
                    .AddEasingKeyFrame(0.0, -30)
                    .AddEasingKeyFrame(Duration*0.6, 30)
                    .AddEasingKeyFrame(Duration*0.8, -15)
                    .AddEasingKeyFrame(Duration, 0),
            };
        }
开发者ID:uwper,项目名称:AnimationManager,代码行数:25,代码来源:LightSpeedAnimations.cs


示例16: Remove

 public void Remove(FrameworkElement target, INameScope nameScope, object layerOwner)
 {
     if (Storyboard != null)
     {
         Storyboard.Remove(target, nameScope, layerOwner);
     }
 }
开发者ID:diab0l,项目名称:Granular,代码行数:7,代码来源:StoryboardAction.cs


示例17: Resume

 public void Resume(FrameworkElement target)
 {
     if (Storyboard != null)
     {
         Storyboard.Pause(target);
     }
 }
开发者ID:diab0l,项目名称:Granular,代码行数:7,代码来源:StoryboardAction.cs


示例18: GoToVisualStateAsync

        /// <summary>
        /// Goes to specified visual state, waiting for the transition to complete.
        /// </summary>
        /// <param name="control">
        /// Control to transition.
        /// </param>
        /// <param name="visualStatesHost">
        /// FrameworkElement that defines the visual states
        /// (usually the root of the control's template).
        /// </param>
        /// <param name="stateGroupName">
        /// Name of the state group
        /// (speeds up the search for the state transition storyboard).
        /// </param>
        /// <param name="stateName">
        /// State to transition to.
        /// </param>
        /// <returns>
        /// Awaitable task that completes when the transition storyboard completes.
        /// </returns>
        /// <remarks>
        /// If a state transition storyboard is not found - the task
        /// completes immediately.
        /// </remarks>
        public static async Task GoToVisualStateAsync(
            this Control control,
            FrameworkElement visualStatesHost,
            string stateGroupName,
            string stateName)
        {
            var tcs = new TaskCompletionSource<Storyboard>();
            var storyboard = GetStoryboardForVisualState(visualStatesHost, stateGroupName, stateName);

            if (storyboard != null)
            {
                EventHandler eh = null;

                eh = (s, e) =>
                {
                    storyboard.Completed -= eh;
                    tcs.SetResult(storyboard);
                };

                storyboard.Completed += eh;
            }

            VisualStateManager.GoToState(control, stateName, true);

            if (storyboard == null)
            {
                return;
            }

            await tcs.Task;
        }
开发者ID:Syn-McJ,项目名称:PlugToolkit,代码行数:55,代码来源:StoryboardExtensions.cs


示例19: CreateAnimation

 public override IEnumerable<Timeline> CreateAnimation(FrameworkElement element)
 {
     return new Timeline[]
     {
         element.AnimateProperty(AnimationProperty.Opacity)
             .AddDiscreteKeyFrame(0.0, 1),
         element.AnimateProperty(AnimationProperty.Rotation)
             .AddDiscreteKeyFrame(0.0, 0),
         element.AnimateProperty(AnimationProperty.TranslateX)
             .AddDiscreteKeyFrame(0.0, 0),
         element.AnimateProperty(AnimationProperty.TranslateY)
             .AddDiscreteKeyFrame(0.0, 0),
         element.AnimateProperty(AnimationProperty.ScaleX)
             .AddDiscreteKeyFrame(0.0, 1),
         element.AnimateProperty(AnimationProperty.ScaleY)
             .AddDiscreteKeyFrame(0.0, 1),
         element.AnimateProperty(AnimationProperty.RotationX)
             .AddDiscreteKeyFrame(0.0, 0),
         element.AnimateProperty(AnimationProperty.RotationY)
             .AddDiscreteKeyFrame(0.0, 0),
         element.AnimateProperty(AnimationProperty.RotationZ)
             .AddDiscreteKeyFrame(0.0, 0),
         element.AnimatePointProperty(AnimationProperty.RenderTransformOrigin)
             .AddDiscreteKeyFrame(0.0, new Point(0.5, 0.5)),
     };
 }
开发者ID:uwper,项目名称:AnimationManager,代码行数:26,代码来源:ResetAnimation.cs


示例20: CreateAnimation

        public override IEnumerable<Timeline> CreateAnimation(FrameworkElement element)
        {
            var transform = GetTransform(element);

            var animations = new List<Timeline>();
            if (Math.Abs(DistanceY) > 0.001)
                animations.Add(
                    element.AnimateProperty(AnimationProperty.TranslateY)
                        .AddEasingKeyFrame(0.0, transform.TranslateY)
                        .AddEasingKeyFrame(Duration * 0.2, transform.TranslateY)
                        .AddEasingKeyFrame(Duration * 0.4, transform.TranslateY + DistanceY)
                        .AddEasingKeyFrame(Duration * 0.5, transform.TranslateY)
                        .AddEasingKeyFrame(Duration * 0.6, transform.TranslateY + (DistanceY / 2))
                        .AddEasingKeyFrame(Duration * 0.8, transform.TranslateY)
                        .AddEasingKeyFrame(Duration, transform.TranslateY)
                    );
            if (Math.Abs(DistanceX) > 0.001)
                animations.Add(
                    element.AnimateProperty(AnimationProperty.TranslateX)
                        .AddEasingKeyFrame(0.0, transform.TranslateX)
                        .AddEasingKeyFrame(Duration * 0.2, transform.TranslateX)
                        .AddEasingKeyFrame(Duration * 0.4, transform.TranslateX + DistanceX)
                        .AddEasingKeyFrame(Duration * 0.5, transform.TranslateX)
                        .AddEasingKeyFrame(Duration * 0.6, transform.TranslateX + (DistanceX / 2))
                        .AddEasingKeyFrame(Duration * 0.8, transform.TranslateX)
                        .AddEasingKeyFrame(Duration, transform.TranslateX)
                    );
            return animations;
        }
开发者ID:uwper,项目名称:AnimationManager,代码行数:29,代码来源:AttentionAnimations.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FrameworkName类代码示例发布时间:2022-05-24
下一篇:
C# Framework类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap