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

C# Windows.FrameworkElement类代码示例

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

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



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

示例1: AddAdorner

        internal void AddAdorner(
            AdornerLayer treeViewAdornerLayer, FrameworkElement adornedElement, ExplorerEFElement explorerElement,
            ExplorerFrame explorerFrame)
        {
            var adornerY = GetAdornerY(adornedElement, explorerElement, explorerFrame);

            if (adornerY >= 0)
            {
                SearchTickAdorner adorner;
                if (!_adorners.TryGetValue(adornerY, out adorner))
                {
                    adorner = new SearchTickAdorner(adornerY, adornedElement);
                    _adorners[adornerY] = adorner;
                    treeViewAdornerLayer.Add(adorner);

                    // adding adorners in batches of 100 - see bug: Windows OS Bugs 1750717 
                    if ((_adorners.Count % 100) == 0)
                    {
                        treeViewAdornerLayer.UpdateLayout();
                    }
                }

                adorner.AddExplorerElement(explorerElement);
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:25,代码来源:SearchAdornerDecorator.cs


示例2: ShowChildWindow

 public void ShowChildWindow(FrameworkElement content)
 {
     XmlContent = content;
     OnPropertyChanged("XmlContent");
     WindowVisibility = Visibility.Visible;
     OnPropertyChanged("WindowVisibility");
 }
开发者ID:Stefanying,项目名称:ControllerCenter.MVVM,代码行数:7,代码来源:ChildWindowManager.cs


示例3: UIAdorner

 public UIAdorner(FrameworkElement adornee, FrameworkElement content)
     : base(adornee)
 {
     this.adornee = adornee;
     this.content = content;
     AddVisualChild(this.content);
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:7,代码来源:UIAdorner.cs


示例4: OnLoaded

        public void OnLoaded(object sender, EventArgs e)
        {
            // Enable moving the window when clicking on the control CtlMoveable 
            this.CtlMoveable = (FrameworkElement)this.Template.FindName("CtlMoveable", this);
            if (null != this.CtlMoveable)
            {
                this.CtlMoveable.MouseLeftButtonDown += new MouseButtonEventHandler(OnMoveableClick);
            }

            Application.Current.MainWindow = this;

            // Disable Minimize and close buttons
            var BtnClose = (FrameworkElement)this.Template.FindName("BtnClose", this);
            if (BtnClose != null)
                BtnClose.Visibility = System.Windows.Visibility.Hidden;

            var BtnMinimize = (FrameworkElement)this.Template.FindName("BtnMinimize", this);
            if (BtnMinimize != null)
                BtnMinimize.Visibility = System.Windows.Visibility.Hidden;

            // Check for updates async
            // and register an event to catch its answer
            vm.LoadApplicationData();
            vm.SelfUpdaterApp.PropertyChanged += vm_PropertyChanged;
            vm.UpdateSelfUpdaterAsync();
            CtlProgress.Maximum = 1;
        }
开发者ID:RononDex,项目名称:Sun.Plasma,代码行数:27,代码来源:UpdateSelfUpdater.xaml.cs


示例5: SetUpdateBindingOnChange

        public static void SetUpdateBindingOnChange(FrameworkElement element, bool value)
        {
            Action<TextBox, bool> action = (txtBox, updateValue) =>
            {
                if (GetUpdateBindingOnChange(txtBox) == updateValue) return;

                if (updateValue)
                {
                    txtBox.TextChanged += element_TextChanged;
                }
                else
                {
                    txtBox.TextChanged -= element_TextChanged;
                }

                txtBox.SetValue(UpdateBindingOnChangeProperty, updateValue);
            };

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (element is TextBox)
                {
                    action.Invoke(element as TextBox, value);
                    return;
                }

                element.GetChildrens<TextBox>().ForEach(i => action.Invoke(i, value));
            });
        }
开发者ID:Rakoun,项目名称:librometer,代码行数:29,代码来源:TextBoxExtension.cs


示例6: Detach

 public void Detach(FrameworkElement element)
 {
     element.MouseMove -= MouseMoveHandler;
     element.MouseRightButtonDown -= MouseDownHandler;
     element.MouseRightButtonUp -= MouseUpHandler;
     element.MouseWheel -= OnMouseWheel;
 }
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:7,代码来源:TrackBall.cs


示例7: StateWellDefined

        public static bool StateWellDefined(FrameworkElement element, string stateName, bool prefixControlName = false)
        {
            string state = string.IsNullOrWhiteSpace(stateName) ? null : (prefixControlName ? element.Name + "_" + 
                stateName : stateName);

            // Look for the visual state on the first child object.  This is generally where states are declared
            // when they are part of a ControlTemplate.
            FrameworkElement child = null;
            if (VisualTreeHelper.GetChildrenCount(element) > 0)
                child = VisualTreeHelper.GetChild(element, 0) as FrameworkElement;

            if (child == null)
                return false;

            var vsgs = VisualStateManager.GetVisualStateGroups(child);
            if (vsgs != null && vsgs.Count > 0)
            {
                foreach (VisualStateGroup vsg in vsgs)
                {
                    if (vsg.States != null)
                    {
                        foreach (VisualState vs in vsg.States)
                        {
                            if (vs.Name == state)
                                return true;
                        }
                    }
                }
            }
            return false;
        }
开发者ID:yulifengwx,项目名称:arcgis-viewer-silverlight,代码行数:31,代码来源:VisualStateManagerHelper.cs


示例8: IsMouseOver

 /// <summary>
 /// Return wheter the mouse is over a control
 /// </summary>
 /// <param name="s"></param>
 /// <param name="e"></param>
 /// <returns>True if the mouse is over a control, false otherwise</returns>
 internal static bool IsMouseOver(FrameworkElement s, System.Windows.Input.MouseEventArgs e)
 {
     Rect bounds = new Rect(0, 0, s.ActualWidth, s.ActualHeight);
     if (bounds.Contains(e.GetPosition(s)))
         return true;
     return false;
 }
开发者ID:Sugz,项目名称:SugzTools,代码行数:13,代码来源:Helpers.cs


示例9: SetupTargetBinding

        public void SetupTargetBinding(FrameworkElement targetObject)
        {
            if (targetObject == null)
            {
                return;
            }

            // Prevent the designer from reporting exceptions since
            // changes will be made of a Binding in use if it is set
            if (DesignerProperties.GetIsInDesignMode(this) == true)
                return;

            // Bind to the selected TargetProperty, e.g. ActualHeight and get
            // notified about changes in OnTargetPropertyListenerChanged
            var listenerBinding = new Binding
            {
                Source = targetObject,
                Path = new PropertyPath(TargetProperty),
                Mode = BindingMode.OneWay
            };
            BindingOperations.SetBinding(this, TargetPropertyListenerProperty, listenerBinding);

            // Set up a OneWayToSource Binding with the Binding declared in Xaml from
            // the Mirror property of this class. The mirror property will be updated
            // everytime the Listener property gets updated
            BindingOperations.SetBinding(this, TargetPropertyMirrorProperty, Binding);
            TargetPropertyValueChanged();
        }
开发者ID:vnl,项目名称:Monies,代码行数:28,代码来源:PushBinding.cs


示例10: CreateBlockBox

        public static Border CreateBlockBox(FrameworkElement child, double width, double height, double x, double y, Color backgroundColor)
        {
            var border = new Border()
            {
                BorderThickness = new Thickness(1, 1, 1, 1),
                BorderBrush = Brushes.Silver,
                Background = new SolidColorBrush(backgroundColor),

                Width = width,
                Height = height,
                Margin = new Thickness(x, y, 0, 0),
                Child = child
            };

            border.MouseEnter += (s, e) =>
            {
                border.Width = Math.Max(width, child.ActualWidth);
                border.Height = Math.Max(height, child.ActualHeight);
                Panel parent = (Panel)border.Parent;
                border.TopMost();
            };

            border.MouseLeave += (s, e) =>
            {
                border.Width = width;
                border.Height = height;
            };

            return border;
        }
开发者ID:breslavsky,项目名称:queue,代码行数:30,代码来源:QueueMonitorControl.xaml.cs


示例11: CloseExists

        public void CloseExists()
        {
            CreateContainerWithRealMessageBus();

            var title = Guid.NewGuid().ToString();

            var viewModel = Substitute.For<ITitledViewModel>();
            viewModel.Title.Returns(title);

            var view = new FrameworkElement();
            view.DataContext = viewModel;
            var viewTarget = ViewTargets.DefaultView;

            var viewResult = new ViewResult(view, viewTarget);
            var viewBuilder = Substitute.For<IViewFactory>();
            viewBuilder.Build(Arg.Any<ViewTargets>(), Arg.Any<Object>())
                .Returns(viewResult);
            ComponentContainer.Container.Register(Component.For<IViewFactory>().Instance(viewBuilder));

            var window = new Window();
            var tabControl = new TabControl();
            var viewController = new ViewPlacer(window, tabControl);
            var newTabItem = new TabItem() { Header = title };
            tabControl.Items.Add(newTabItem);

            var message = new CloseViewMessage(title);
            _MessageBus.Publish<CloseViewMessage>(message);

            Assert.AreEqual(0, tabControl.Items.Count);
        }
开发者ID:brentedwards,项目名称:MvvmFabric,代码行数:30,代码来源:ViewPlacerTests.cs


示例12: ModifyNewContent

        protected override FrameworkElement ModifyNewContent(ITransitionControl container, FrameworkElement newContent)
        {
            if (newContent == null)
            {
                HideBackground(container);
                container.Remove(_border);
                return null;
            }

            ShowBackground(container);

            _border = WrapInBorder(newContent);

            _border.Opacity = 0;

            SetPosition(_border);

            newContent.SizeChanged += (sender, e) => SetPosition(_border);

            var ctrl = container.AsControl();

            ctrl.SizeChanged += (sender, e) => SetPosition(_border);

            return _border;
        }
开发者ID:RookieOne,项目名称:Chimera,代码行数:25,代码来源:ModalAnimationStrategy.cs


示例13: Bind

        public static void Bind(FrameworkElement view, object viewModel)
        {
            Log.Info($"Binding '{view}' to '{viewModel}'");

            var namedElements = UIHelper.FindNamedChildren(view);

            var viewModelProperties = viewModel.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

            var matches = namedElements.Join(viewModelProperties, e => e.Name, p => p.Name, (e, p) => new { e, p });

            foreach (var element in namedElements)
            {
                var matchingProperty = viewModelProperties.Where(p => p.Name == element.Name).SingleOrDefault();
                if (matchingProperty == null)
                {
                    Log.Debug($"No matching property for element '{element.Name}'");
                    continue;
                }

                if (!TryBind(element, matchingProperty, viewModel))
                    Log.Debug($"Could not bind element '{element.Name}' to property '{matchingProperty.Name}'");
            }

            view.DataContext = viewModel;

            var viewAware = viewModel as IViewAware;
            viewAware?.AttachView(view);
        }
开发者ID:distantcam,项目名称:ServiceInsight2,代码行数:28,代码来源:ViewModelBinder.cs


示例14: Show

 public void Show(FrameworkElement popupContent)
 {
     _PopupContent = popupContent;
     _Popup = new Popup();
     _Popup.Child = this;
     _Popup.IsOpen = true;
 }
开发者ID:ziibinj,项目名称:DataEncryptWindowsPhoneDemo,代码行数:7,代码来源:PopupCotainer.xaml.cs


示例15: VoteVisible

 public static void VoteVisible(FrameworkElement fe)
 {
     foreach (var item in fe.LogicalParents().TakeWhile(a => GetAutoHide(a) != AutoHide.Visible))
     {
         SetAutoHide(item, AutoHide.Visible);
     }
 }
开发者ID:rondoo,项目名称:framework,代码行数:7,代码来源:Common.cs


示例16: Attach

 public void Attach(FrameworkElement element)
 {
     element.MouseMove += MouseMoveHandler;
     element.MouseRightButtonDown += MouseDownHandler;
     element.MouseRightButtonUp += MouseUpHandler;
     element.MouseWheel += OnMouseWheel;
 }
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:7,代码来源:TrackBall.cs


示例17: VoteCollapsed

 public static void VoteCollapsed(FrameworkElement fe)
 {
     foreach (var item in fe.LogicalParents().TakeWhile(a => GetAutoHide(a) == AutoHide.Undefined))
     {
         SetAutoHide(item, AutoHide.Collapsed);
     }
 }
开发者ID:rondoo,项目名称:framework,代码行数:7,代码来源:Common.cs


示例18: Open

 public void Open(FrameworkElement container)
 {
     if (container != null)
     {
         _container = container;
         // 通过禁用来模拟模态的对话框
         _container.IsEnabled = false;
         // 保持总在最上
         this.Owner = GetOwnerWindow(container);
         if (this.Owner != null)
         {
             this.Owner.Closing += new System.ComponentModel.CancelEventHandler(Owner_Closing);
         }
         // 通过监听容器的Loaded和Unloaded来显示/隐藏窗口
         _container.Loaded += new RoutedEventHandler(Container_Loaded);
         _container.Unloaded += new RoutedEventHandler(Container_Unloaded);
     }
     this.Show();
     try
     {
         ComponentDispatcher.PushModal();
         _dispatcherFrame = new DispatcherFrame(true);
         Dispatcher.PushFrame(_dispatcherFrame);
     }
     finally
     {
         ComponentDispatcher.PopModal();
     }
 }
开发者ID:xdusongwei,项目名称:ErlangEditor,代码行数:29,代码来源:MyDialog.cs


示例19: ReplaceContent

        /// <summary>
        /// Replaces the content for a <see cref="DataField"/> with another control and updates the bindings.
        /// </summary>
        /// <param name="field">The <see cref="DataField"/> whose <see cref="TextBox"/> will be replaced.</param>
        /// <param name="newControl">The new control you're going to set as <see cref="DataField.Content" />.</param>
        /// <param name="dataBindingProperty">The control's property that will be used for data binding.</param>        
        /// <param name="bindingSetupFunction">
        ///  An optional <see cref="Action"/> you can use to change parameters on the newly generated binding before
        ///  it is applied to <paramref name="newControl"/>
        /// </param>
        /// <param name="sourceProperty">The source dependency property to use for the binding.</param>
        public static void ReplaceContent(this DataField field, FrameworkElement newControl, DependencyProperty dataBindingProperty, Action<Binding> bindingSetupFunction, DependencyProperty sourceProperty)
        {
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }

            if (newControl == null)
            {
                throw new ArgumentNullException("newControl");
            }

            // Construct new binding by copying existing one, and sending it to bindingSetupFunction
            // for any changes the caller wants to perform
            Binding newBinding = field.Content.GetBindingExpression(sourceProperty).ParentBinding.CreateCopy();

            if (bindingSetupFunction != null)
            {
                bindingSetupFunction(newBinding);
            }

            // Replace field
            newControl.SetBinding(dataBindingProperty, newBinding);
            field.Content = newControl;
        }
开发者ID:jeffhandley,项目名称:RIAServicesValidation,代码行数:36,代码来源:DataFieldExtensions.cs


示例20: CreateIcon

        public static void CreateIcon(FrameworkElement element, int width, int height, string path)
        {
            try
            {
                RenderTargetBitmap bmp = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);
                bmp.Render(element);

                string file = path;

                string Extension = Path.GetExtension(file).ToLower();

                BitmapEncoder encoder;
                if (Extension == ".gif")
                    encoder = new GifBitmapEncoder();
                else if (Extension == ".png")
                    encoder = new PngBitmapEncoder();
                else if (Extension == ".jpg")
                    encoder = new JpegBitmapEncoder();
                else
                    return;

                encoder.Frames.Add(BitmapFrame.Create(bmp));

                using (Stream stm = File.Create(file))
                {
                    encoder.Save(stm);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:alexsorokoletov,项目名称:ImagePreparator,代码行数:33,代码来源:IconsGenerator.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Windows.FrameworkElementFactory类代码示例发布时间:2022-05-26
下一篇:
C# Windows.FrameworkContentElement类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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