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


C# Popup.SetBinding方法代码示例

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


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

示例1: PopupButton

		public PopupButton()
		{
			var content = new ContentPresenter();
			content.SetBinding(ContentPresenter.ContentProperty, new Binding("PopupContent") { Source = this });
			var border = new Border()
			{
				CornerRadius = new CornerRadius(5),
				BorderThickness = new Thickness(1),
				Child = content
			};
			border.SetResourceReference(Border.BackgroundProperty, "BaseWindowBackgroundBrush");
			border.SetResourceReference(Border.BorderBrushProperty, "WindowBorderBrush");
			_popup = new Popup()
			{
				AllowsTransparency = true,
				StaysOpen = false,
				Placement = PlacementMode.Bottom,
				PlacementTarget = this,
				DataContext = this,
				Child = border,
			};
			_popup.SetBinding(Popup.IsOpenProperty, "IsChecked");
			_popup.SetBinding(Popup.WidthProperty, "Width");
			SetBinding(PopupButton.IsHitTestVisibleProperty, new Binding("IsOpen") { Source = _popup, Mode = BindingMode.OneWay, Converter = new InverseBooleanConverter() });
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:25,代码来源:PopupButton.cs

示例2: OnApplyTemplate

        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code 
        /// or internal processes call System.Windows.FrameworkElement.ApplyTemplate().
        /// </summary>
        public override void OnApplyTemplate()
        {
            // Clear cache
            cachedMeasures.Clear();

            if (LauncherButton != null) LauncherButton.Click -= OnDialogLauncherButtonClick;
            LauncherButton = GetTemplateChild("PART_DialogLauncherButton") as Button;
            if (LauncherButton != null)
            {
                LauncherButton.Click += OnDialogLauncherButtonClick;
                if (LauncherKeys != null)
                    KeyTip.SetKeys(LauncherButton, LauncherKeys);
            }

            popup = GetTemplateChild("PART_Popup") as Popup;
            if (popup != null)
            {
                Binding binding = new Binding("IsOpen");
                binding.Mode = BindingMode.TwoWay;
                binding.Source = this;
                popup.SetBinding(Popup.IsOpenProperty, binding);
            }

            downGrid = GetTemplateChild("PART_DownGrid") as Grid;
            upPanel = GetTemplateChild("PART_UpPanel") as Panel;
            parentPanel = GetTemplateChild("PART_ParentPanel") as Panel;
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:31,代码来源:RibbonGroupBox.cs

示例3: GlyphIconButton_WithPopup

		public GlyphIconButton_WithPopup()
		{
			Popup = new Popup()
			{
				AllowsTransparency = true,
			};
			var contentControl = new ContentControl()
			{
				Focusable = false,
				IsTabStop = false,

			};
			contentControl.SetBinding(ContentProperty, new Binding() {Source = this, Path = new PropertyPath($"{nameof(PopupContent)}")});
			contentControl.SetBinding(ContentTemplateProperty, new Binding() {Source = this, Path = new PropertyPath($"{nameof(PopupContentTemplate)}")});
			Popup.Child = new Border
			{
				Child = contentControl,
				Effect = new DropShadowEffect() {BlurRadius = 10, Color = Colors.Black, Opacity = 1, ShadowDepth = 0},
				Margin = new Thickness(10),
			};
			Popup.SetBinding(Popup.IsOpenProperty, new Binding() {Source = this, Path = new PropertyPath($"{nameof(IsOpened)}")});
			Popup.SetBinding(Popup.PlacementTargetProperty, new Binding() {Source = this, Path = new PropertyPath($"{nameof(PopupPlacementTarget)}")});
			Popup.SetBinding(Popup.StaysOpenProperty, new Binding() {Source = this, Path = new PropertyPath($"{nameof(StaysOpen)}")});
			Popup.Placement = PlacementMode.Bottom;
			AddLogicalChild(Popup);
			Click += GlyphIconButton_WithPopup_Click;
		}
开发者ID:cssack,项目名称:CsGlobals,代码行数:27,代码来源:GlyphIconButton_WithPopup.xaml.cs

示例4: SetupRxPopup

        static void SetupRxPopup(object rootModel, UIElement view, Popup popup) {
            var isOpen = rootModel as IIsOpen;
            if (isOpen != null) {
                isOpen.IsOpen = true;
                popup.SetBinding(Popup.IsOpenProperty, new Binding("IsOpen") {Mode = BindingMode.TwoWay});
                popup.SetBinding(Popup.StaysOpenProperty, new Binding("StaysOpen") {Mode = BindingMode.TwoWay});
            }

            var vFor = view as IViewFor;
            if (vFor == null)
                return;
            var rxClose = rootModel as IRxClose;
            if (rxClose != null) {
                // Is this how we want to do it?
                vFor.WhenActivated(
                    d => {
                        d(
                            rxClose.Close.ObserveOn(RxApp.MainThreadScheduler)
                                .Subscribe(x => { popup.IsOpen = !popup.IsOpen; }));
                    });
            }
        }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:22,代码来源:CustomWindowManager.cs

示例5: OnApplyTemplate

        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or 
        /// internal processes call System.Windows.FrameworkElement.ApplyTemplate().
        /// </summary>
        public override void OnApplyTemplate()
        {
            popup = GetTemplateChild("PART_Popup") as Popup;
            if (popup != null)
            {
                Binding binding = new Binding("IsOpen");
                binding.Mode = BindingMode.TwoWay;
                binding.Source = this;
                popup.SetBinding(Popup.IsOpenProperty, binding);

                popup.CustomPopupPlacementCallback = CustomPopupPlacementMethod;
            }
            if ((ToolbarPanel != null) && (toolBarItems != null))
            {
                for (int i = 0; i < toolBarItems.Count; i++)
                {
                    ToolbarPanel.Children.Remove(toolBarItems[i]);
                }
            }
            toolbarPanel = GetTemplateChild("PART_ToolbarPanel") as Panel;
            if ((ToolbarPanel != null) && (toolBarItems != null))
            {
                for (int i = 0; i < toolBarItems.Count; i++)
                {
                    ToolbarPanel.Children.Add(toolBarItems[i]);
                }
            }
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:32,代码来源:RibbonTabControl.cs

示例6: HandleLoaded

        private void HandleLoaded(object sender, RoutedEventArgs e)
        {
            popup = new Popup();

            view = new DocumentPadView() {DataContext = ApplicationModel.Current.DocumentPad};

            ResizablePopupFrameBehavior.SetParentPopup(view, popup);
            ResizablePopupFrameBehavior.SetResizeBounds(view, GetCurrentPopupBounds());

            view.Width = 300;
            view.Height = 300;

            PropertyChangedEventHandler documentPadOnPropertyChanged = null;
            documentPadOnPropertyChanged = (s, args) =>
            {
                ApplicationModel.Current.DocumentPad.PropertyChanged -= documentPadOnPropertyChanged;
                var bounds = GetCurrentPopupBounds();
                if (args.PropertyName == "IsOpen")
                {
                    popup.HorizontalOffset = bounds.Right - view.Width;
                    popup.VerticalOffset = bounds.Bottom - view.Height;
                }
            };

            ApplicationModel.Current.DocumentPad.PropertyChanged += documentPadOnPropertyChanged;
            

            popup.Child = view;
            popup.SetBinding(Popup.IsOpenProperty, new Binding("IsOpen") {Source = ApplicationModel.Current.DocumentPad});
        }
开发者ID:925coder,项目名称:ravendb,代码行数:30,代码来源:DocumentPadLayer.xaml.cs

示例7: CreateRootPopup

        /// <summary>
        ///     Hooks up a Popup to a child.
        ///     The child will be required to implement the following properties:
        ///         Popup.IsOpenProperty
        ///         Popup.PlacementProperty
        ///         Popup.PlacementRectangleProperty
        ///         Popup.PlacementTargetProperty
        ///         Popup.HorizontalOffsetProperty
        ///         Popup.VerticalOffsetProperty
        /// </summary>
        /// <param name="popup">The parent popup that the child will be hooked up to.</param>
        /// <param name="child">The element to be the child of the popup.</param>
        public static void CreateRootPopup(Popup popup, UIElement child)
        {
            if (popup == null)
            {
                throw new ArgumentNullException("popup");
            }
            if (child == null)
            {
                throw new ArgumentNullException("child");
            }

            // When we get here, the Child must not have already been visually or logically parented.
            object currentParent = null;
            if ((currentParent = LogicalTreeHelper.GetParent(child)) != null)
            {
                throw new InvalidOperationException(SR.Get(SRID.CreateRootPopup_ChildHasLogicalParent, child, currentParent));
            }

            if ((currentParent = VisualTreeHelper.GetParent(child)) != null)
            {
                throw new InvalidOperationException(SR.Get(SRID.CreateRootPopup_ChildHasVisualParent, child, currentParent));
            }

            // PlacementTarget must be set before hooking up the child so that resource
            // lookups can work.  The Popup for tooltip and context menu isn't in the tree
            // so FE relies on GetUIParentCore to return the placement target as the
            // effective logical parent
            Binding binding = new Binding("PlacementTarget");
            binding.Mode = BindingMode.OneWay;
            binding.Source = child;
            popup.SetBinding(PlacementTargetProperty, binding);

            // NOTE: this will hook up child as a logical child of Popup.
            // If at a later date this is not desired, then modify the hookup to avoid the logical hookup.
            //
            // NOTE: Logical linking is necessary if property invalidations are to propagate down
            // the tree into the child (unless at a later date an alternate method has been created).
            popup.Child = child;

            binding = new Binding("VerticalOffset");
            binding.Mode = BindingMode.OneWay;
            binding.Source = child;
            popup.SetBinding(VerticalOffsetProperty, binding);

            binding = new Binding("HorizontalOffset");
            binding.Mode = BindingMode.OneWay;
            binding.Source = child;
            popup.SetBinding(HorizontalOffsetProperty, binding);

            binding = new Binding("PlacementRectangle");
            binding.Mode = BindingMode.OneWay;
            binding.Source = child;
            popup.SetBinding(PlacementRectangleProperty, binding);

            binding = new Binding("Placement");
            binding.Mode = BindingMode.OneWay;
            binding.Source = child;
            popup.SetBinding(PlacementProperty, binding);

            binding = new Binding("StaysOpen");
            binding.Mode = BindingMode.OneWay;
            binding.Source = child;
            popup.SetBinding(StaysOpenProperty, binding);

            binding = new Binding("CustomPopupPlacementCallback");
            binding.Mode = BindingMode.OneWay;
            binding.Source = child;
            popup.SetBinding(CustomPopupPlacementCallbackProperty, binding);

            // Note: IsOpen should always be last in this method
            binding = new Binding("IsOpen");
            binding.Mode = BindingMode.OneWay;
            binding.Source = child;
            popup.SetBinding(IsOpenProperty, binding);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:87,代码来源:Popup.cs


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