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


C# ToolTip.SetBinding方法代码示例

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


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

示例1: VisitInternal

        protected override void VisitInternal(BindingInformation info, FormResult result, object service)
        {
            IEditableService typedService = (IEditableService)service;

            FrameworkElement element = (FrameworkElement)result.EditorElement;

            string editablePropertyName = PropertyUtil<IEditableService>.GetPropertyName(s => s.Editable);
            string reasonPropertyName = PropertyUtil<IEditableService>.GetPropertyName(s => s.DisabledReason);

            Binding enabledBinding = new Binding(editablePropertyName);
            enabledBinding.Source = service;

            element.SetBinding(UIElement.IsEnabledProperty, enabledBinding);

            Binding tooltipVisibleBinding = new Binding(editablePropertyName);
            tooltipVisibleBinding.Source = service;
            tooltipVisibleBinding.Converter = new CustomBooleanToVisibilityConverter(true);

            Binding tooltipTextBinding = new Binding(reasonPropertyName);
            tooltipTextBinding.Source = service;

            ToolTip tooltip = new ToolTip();
            tooltip.SetBinding(UIElement.VisibilityProperty, tooltipVisibleBinding);
            tooltip.SetBinding(ContentControl.ContentProperty, tooltipTextBinding);

            element.ToolTip	= tooltip;
        }
开发者ID:RobinKu,项目名称:Cio,代码行数:27,代码来源:EditableServiceVisitor.cs

示例2: AddToolTip

 private static void AddToolTip(DependencyObject obj)
 {
     if (ToolTipService.GetToolTip(obj) is ToolTip)
         return;
     ToolTip toolTip = new ToolTip();
     toolTip.SetBinding(ContentControl.ContentProperty, (BindingBase)new Binding("ToolTipContent"));
     toolTip.SetBinding(FrameworkElement.StyleProperty, (BindingBase)new Binding("ToolTipStyle"));
     ToolTipService.SetToolTip(obj, (object)toolTip);
 }
开发者ID:sulerzh,项目名称:chart,代码行数:9,代码来源:SeriesTooltipPresenter.cs

示例3: SimpleUIBoundToCustomer

        public SimpleUIBoundToCustomer()
        {
            var stack = new StackPanel();
            Content = stack;

            var textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("FirstName"));
            stack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("LstName")); //purposefully misspelled
            stack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding()); //context
            stack.Children.Add(textBlock);

            var checkbox = new CheckBox();
            checkbox.SetBinding(CheckBox.IsCheckedProperty, new Binding("asdfsdf")); //does not exist
            stack.Children.Add(checkbox);

            var tooltip = new ToolTip();
            tooltip.SetBinding(System.Windows.Controls.ToolTip.ContentProperty, new Binding("asdfasdasdf")); // does not exist
            stack.ToolTip = tooltip;

            var childUserControl = new SimpleUIBoundToCustomerByAttachedPorperty();
            stack.Children.Add(childUserControl);
        }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:28,代码来源:SimpleUIBoundToCustomer.cs

示例4: FillInformationLayer

        private void FillInformationLayer()
        {
            // Create extended property set.
            // It can be shared between the number
            // of the map shapes.
            ExtendedPropertySet propertySet = new ExtendedPropertySet();
            propertySet.RegisterProperty("Name", "City Name", typeof(string), String.Empty);
            propertySet.RegisterProperty("Population", "Population", typeof(int), 0);

            MapEllipse sofiaEllipse = new MapEllipse()
            {
                ShapeFill = new MapShapeFill()
                {
                    Stroke = new SolidColorBrush(Colors.Red),
                    StrokeThickness = 2,
                    Fill = new SolidColorBrush(Colors.Transparent)
                },
                Width = 20,
                Height = 20,
                Location = new Location(42.6957539183824, 23.3327663758679),
            };

            // Create extended data for the ellipse
            // using existing property set.
            ExtendedData sofiaData = new ExtendedData(propertySet);

            // Set the extended properties.
            sofiaData.SetValue("Name", "Sofia");
            sofiaData.SetValue("Population", 1300000);

            // Assign extended data to the map shape.
            sofiaEllipse.ExtendedData = sofiaData;

            // Assign tooltip which uses the extended properties.
            ToolTip tooltip = new ToolTip();
            Binding tooltipBinding = new Binding()
            {
                Converter = new ExtendedDataConverter(),
                ConverterParameter = "{Name}: {Population} people",
                Source = sofiaEllipse.ExtendedData
            };
            tooltip.SetBinding(System.Windows.Controls.ToolTip.ContentProperty, tooltipBinding);
            ToolTipService.SetToolTip(sofiaEllipse, tooltip);

            this.informationLayer.Items.Add(sofiaEllipse);
        }
开发者ID:JoelWeber,项目名称:xaml-sdk,代码行数:46,代码来源:MainWindow.xaml.cs

示例5: SetConnectorLabelToolTip

 void SetConnectorLabelToolTip(Connector connector, BindingBase binding)
 {
     connector.SetBinding(Connector.LabelTextProperty, binding);
     ToolTip toolTip = new ToolTip();
     toolTip.SetBinding(UserControl.ContentProperty, binding);
     connector.SetLabelToolTip(toolTip);
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:FlowchartDesigner.xaml.cs

示例6: ServerControls_DataContextChanged

 void ServerControls_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     ToolTip myToolTip = new ToolTip();
     myToolTip.FontFamily = App.Current.Resources["FontFamily"] as FontFamily;
     myToolTip.FontSize = 16;
     myToolTip.FontWeight = FontWeights.Black;
     Binding myBinding = new Binding(strBindingElement);
     myBinding.Source = this.DataContext;
     myToolTip.SetBinding(System.Windows.Controls.ToolTip.ContentProperty, myBinding);
     this.ToolTip = myToolTip;
 }
开发者ID:swganhtools,项目名称:swganhclientlauncher,代码行数:11,代码来源:ServerControls.cs

示例7: OnApplyTemplate

        //public ServerControls(ButtonType theButtonType, string strToolTip)
        //{
        //    TheButtonType = theButtonType;
        //    this.GroupName = "ServerControls";
        //    ToolTipText = strToolTip;
        //}
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            //find the image
            Image leImage = (Image)this.Template.FindName("image", this);
            BitmapImage theSource = new BitmapImage();
            theSource.BeginInit();

            try
            {
                switch (TheButtonType)
                {
                    case ButtonType.ChooseGalaxy:
                        theSource.UriSource = new Uri("pack://application:,,,/Images/galaxy.png", UriKind.RelativeOrAbsolute);
                        strBindingElement = "ChooseGalaxy";
                        break;
                    case ButtonType.Language:
                        theSource.UriSource = new Uri("pack://application:,,,/Images/language.png", UriKind.RelativeOrAbsolute);
                        strBindingElement = "ChangeLanguage";
                        break;
                    case ButtonType.News:
                        theSource.UriSource = new Uri("pack://application:,,,/Images/info.png", UriKind.RelativeOrAbsolute);
                        strBindingElement = "ServerNews";
                        break;
                    case ButtonType.ClientPatcher:
                        theSource.UriSource = new Uri("pack://application:,,,/Images/check.png", UriKind.RelativeOrAbsolute);
                        strBindingElement = "ClientPatcher";
                        break;
                    case ButtonType.Settings:
                        theSource.UriSource = new Uri("pack://application:,,,/Images/settings.png", UriKind.RelativeOrAbsolute);
                        strBindingElement = "Settings";
                        break;
                    case ButtonType.ClientLauncher:
                        theSource.UriSource = new Uri("pack://application:,,,/Images/Launch.png", UriKind.RelativeOrAbsolute);
                        strBindingElement = "GameLauncher";
                        break;
                }
            }
            catch (Exception ex)
            {
                string atr = ex.Message;
            }
            theSource.EndInit();

            leImage.Source = theSource;

            //set the tooltip if we have one
            if (!string.IsNullOrEmpty(strBindingElement))
            {
                ToolTip myToolTip = new ToolTip();
                myToolTip.FontFamily = App.Current.Resources["FontFamily"] as FontFamily;
                myToolTip.FontSize = 16;
                myToolTip.FontWeight = FontWeights.Black;
                Binding myBinding = new Binding(strBindingElement);
                myBinding.Source = this.DataContext;
                myToolTip.SetBinding(System.Windows.Controls.ToolTip.ContentProperty, myBinding);
                this.ToolTip = myToolTip;
            }
        }
开发者ID:swganhtools,项目名称:swganhclientlauncher,代码行数:66,代码来源:ServerControls.cs

示例8: HandleDoubleClick


//.........这里部分代码省略.........
            urGridView.Columns.Add(gvc2);

            GridViewColumn gvc3 = new GridViewColumn();
            GridViewColumnHeader gvc3H = new GridViewColumnHeader();

            gvc3H.FontSize = 11;
            gvc3H.Width = 120;
            gvc3H.Content = " Progress";
            gvc3H.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;
            gvc3.DisplayMemberBinding = new Binding("UserProgressMsg");
            gvc3.Header = gvc3H;
            urGridView.Columns.Add(gvc3);

            urListView[accountnum].View = urGridView;

            urGrid.Children.Add(urListView[accountnum]);
            //

            // now create Listbox for errors
            lbErrors[accountnum] = new ListBox();
            lbErrors[accountnum].FontSize = 11;
            lbErrors[accountnum].SetValue(Grid.RowProperty, 1);
            lbErrors[accountnum].Margin = new Thickness(5, 5, 5, 5);
            lbErrors[accountnum].MinHeight = 120;
            lbErrors[accountnum].MaxHeight = 120;
            lbErrors[accountnum].MinWidth = 450;
            lbErrors[accountnum].HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            lbErrors[accountnum].VerticalAlignment = System.Windows.VerticalAlignment.Top;
            urGrid.Children.Add(lbErrors[accountnum]);
            //

            // Now set up the progressbar and message status in another grid
            userProgressBar = new ProgressBar();
            userProgressBar.SetValue(Grid.RowProperty, 2);
            userProgressBar.SetValue(Grid.ColumnProperty, 0);
            userProgressBar.SetValue(Grid.ColumnSpanProperty, 2);
            userProgressBar.IsIndeterminate = false;
            userProgressBar.Orientation = Orientation.Horizontal;
            userProgressBar.Width = 412;
            userProgressBar.Height = 18;
            userProgressBar.Margin = new Thickness(36, 0, 0, 0);
            userProgressBar.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;

            // FBS bug 74960 -- 6/1/12
            ToolTip tooltip = new ToolTip();
            Binding tbBinding = new Binding("GlobalAcctProgressMsg");
            tbBinding.Source = ar;
            tooltip.SetBinding(ContentControl.ContentProperty, tbBinding);
            ToolTipService.SetToolTip(userProgressBar, tooltip);

            // Change the background and foreground colors
            SolidColorBrush scbBack = new SolidColorBrush();
            scbBack.Color = Color.FromArgb(255, 218, 227, 235);   // #FFDAE3EB
            userProgressBar.Background = scbBack;
            userProgressBar.Foreground = Brushes.DodgerBlue;
            ///

            Binding upbBinding = new Binding("PBValue");
            upbBinding.Source = ar;
            userProgressBar.SetBinding(ProgressBar.ValueProperty, upbBinding);
            if (!ViewModel.GetScheduleViewModel().IsPreviewMode())
            {
                urGrid.Children.Add(userProgressBar);
            }

            userStatusMsg = new Label();
            userStatusMsg.Visibility = System.Windows.Visibility.Visible;
            userStatusMsg.SetValue(Grid.RowProperty, 3);
            userStatusMsg.SetValue(Grid.ColumnProperty, 0);
            userStatusMsg.SetValue(Grid.ColumnSpanProperty, 2);
            userStatusMsg.MinWidth = 300;
            userStatusMsg.Margin = new Thickness(30, 0, 0, 0);
            userStatusMsg.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            userStatusMsg.FontStyle = FontStyles.Italic;
            Binding usmBinding = new Binding("PBMsgValue");
            usmBinding.Source = ar;
            userStatusMsg.SetBinding(Label.ContentProperty, usmBinding);
            urGrid.Children.Add(userStatusMsg);
            //////////////

            userItem.Content = urGrid;

            tabCtrl.Items.Add(userItem);
            userItem.IsSelected = true;

            Binding binding = new Binding();

            // wrap in NotifyCollectionChangedWrapper so we can update collection from a different thread
            binding.Source = new NotifyCollectionChangedWrapper<UserResultsViewModel>(ar.UserResultsList);
            //

            BindingOperations.SetBinding(urListView[accountnum], ListView.ItemsSourceProperty,
                binding);
            }
            catch (Exception excep)
            {
            Log.err("error when get usermigration information " + excep.Message);

            }
        }
开发者ID:Ppalanivelu,项目名称:zimbra-sources,代码行数:101,代码来源:ResultsView.xaml.cs

示例9: RaiseToolTipOpeningEvent

        private void RaiseToolTipOpeningEvent()
        {
            ResetToolTipTimer();

            if (_forceCloseTimer != null)
            {
                OnForceClose(null, EventArgs.Empty);
            }

            DependencyObject o = LastMouseOverWithToolTip;
            if (o != null)
            {
                bool show = true;

                IInputElement element = o as IInputElement;
                if (element != null)
                {
                    ToolTipEventArgs args = new ToolTipEventArgs(true);
                    element.RaiseEvent(args);

                    show = !args.Handled;
                }

                if (show)
                {
                    object tooltip = ToolTipService.GetToolTip(o);
                    ToolTip tip = tooltip as ToolTip;
                    if (tip != null)
                    {
                        _currentToolTip = tip;
                        _ownToolTip = false;
                    }
                    else if ((_currentToolTip == null) || !_ownToolTip)
                    {
                        _currentToolTip = new ToolTip();
                        _ownToolTip = true;
                        _currentToolTip.SetValue(ServiceOwnedProperty, BooleanBoxes.TrueBox);

                        // Bind the content of the tooltip to the ToolTip attached property
                        Binding binding = new Binding();
                        binding.Path = new PropertyPath(ToolTipService.ToolTipProperty);
                        binding.Mode = BindingMode.OneWay;
                        binding.Source = o;
                        _currentToolTip.SetBinding(ToolTip.ContentProperty, binding);
                    }

                    if (!_currentToolTip.StaysOpen)
                    {
                        // The popup takes capture in this case, which causes us to hit test to the wrong window.
                        // We do not support this scenario. Cleanup and then throw and exception.
                        throw new NotSupportedException(SR.Get(SRID.ToolTipStaysOpenFalseNotAllowed));
                    }

                    _currentToolTip.SetValue(OwnerProperty, o);
                    _currentToolTip.Closed += OnToolTipClosed;
                    _currentToolTip.IsOpen = true;

                    ToolTipTimer = new DispatcherTimer(DispatcherPriority.Normal);
                    ToolTipTimer.Interval = TimeSpan.FromMilliseconds(ToolTipService.GetShowDuration(o));
                    ToolTipTimer.Tick += new EventHandler(OnRaiseToolTipClosingEvent);
                    ToolTipTimer.Start();
                }
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:64,代码来源:PopupControlService.cs


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