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


C# FrameworkElement类代码示例

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


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


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