本文整理汇总了C#中System.Windows.Controls.ToolTip类的典型用法代码示例。如果您正苦于以下问题:C# ToolTip类的具体用法?C# ToolTip怎么用?C# ToolTip使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ToolTip类属于System.Windows.Controls命名空间,在下文中一共展示了ToolTip类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RibbonPopup
/// <summary>
/// Default constructor
/// </summary>
public RibbonPopup()
{
Focusable = false;
ToolTip = new ToolTip();
(ToolTip as ToolTip).Template = null;
AddHandler(RibbonControl.ClickEvent, new RoutedEventHandler(OnClick));
}
示例2: ColorGridBox
public ColorGridBox()
{
// Define the ItemsPanel template.
FrameworkElementFactory factoryUnigrid =
new FrameworkElementFactory(typeof(UniformGrid));
factoryUnigrid.SetValue(UniformGrid.ColumnsProperty, 8);
ItemsPanel = new ItemsPanelTemplate(factoryUnigrid);
// Add items to the ListBox.
foreach (string strColor in strColors)
{
// Create Rectangle and add to ListBox.
Rectangle rect = new Rectangle();
rect.Width = 12;
rect.Height = 12;
rect.Margin = new Thickness(4);
rect.Fill = (Brush)
typeof(Brushes).GetProperty(strColor).GetValue(null, null);
Items.Add(rect);
// Create ToolTip for Rectangle.
ToolTip tip = new ToolTip();
tip.Content = strColor;
rect.ToolTip = tip;
}
// Indicate that SelectedValue is Fill property of Rectangle item.
SelectedValuePath = "Fill";
}
示例3: ShowActualWidthToolTip
/// <summary>
/// ShowActualWidthToolTip shows actual width of the left and right column near the GridSplitter column, so one can split two columns precisely
/// </summary>
/// <param name="gs"></param>
/// <param name="tt"></param>
// TODO: MainWindow.ShowActualWidthToolTip seems to be to tricky for reusability, maybe one find a more scaleable solution
private void ShowActualWidthToolTip(GridSplitter gs, ToolTip tt)
{
// If the GridSplitter isn't positioned correctly in a seperate column between two other columns, drop functionality
Grid parentGrid = gs.Parent as Grid;
double? leftColumnActualWidth = null;
double? rightColumnActualWidth = null;
try
{
leftColumnActualWidth = parentGrid.ColumnDefinitions[(Grid.GetColumn(gs) - 1)].ActualWidth;
rightColumnActualWidth = parentGrid.ColumnDefinitions[Grid.GetColumn(gs) + 1].ActualWidth;
}
catch (ArgumentOutOfRangeException ex)
{
MessageBox.Show("Something went wrong in your GridSplitter layout. Splitter must been set in a column between the two columns who method tries to evaluate actual width. \n\n" + ex.Message, "Error", MessageBoxButton.OK);
}
tt.Content = String.Format("\u21E4 Width left {0} | {1} Width right \u21E5", leftColumnActualWidth, rightColumnActualWidth);
tt.PlacementTarget = this;
tt.Placement = PlacementMode.Relative;
tt.HorizontalOffset = (Mouse.GetPosition(this).X - (tt.ActualWidth / 2));
tt.VerticalOffset = (Mouse.GetPosition(this).Y + 10);
tt.IsOpen = true;
return;
}
示例4: ToolTipController
public ToolTipController()
{
myTip = new ToolTip();
myTimer = new DispatcherTimer();
myTimer.Interval = new TimeSpan( ToolTipService.GetInitialShowDelay( myTip ) * 10000 );
myTimer.Tick += new EventHandler( OnTick );
}
示例5: Tower
/*method*/
public Tower(int _hp, int _atk, int _range, int _towerLevel, bool _isPlayer, Grid _grid, Grid _gridTopBar)
{
maxHP = _hp;
hp = _hp;
atk = _atk;
range = _range;
towerLevel = _towerLevel;
_attackspeed = 100;//單位是10毫秒
isEnemy = !_isPlayer;
grid = _grid;
LabelSetting();
grid.Children.Add(ImgTower);
_gridTopBar.Children.Add(lbHP_BG);
_gridTopBar.Children.Add(lbTowerHP);
if (isEnemy)
_axis = 986;//lbTower.Margin.Right;
else
_axis = 108;//lbTower.Margin.Right + lbTower.Width;
tp.Content = "等 級: " + TowerLevel.ToString() + "\n血 量: " + HP.ToString() + '\n' + "射 程: " + RANGE.ToString() + "\n攻擊力: " + ATK.ToString();
tp.Background = Brushes.LightSteelBlue;
tp.BorderBrush = Brushes.Black;
tp.BorderThickness = new Thickness(2);
ImgTower.ToolTip = tp;
ToolTip tmp = new ToolTip();
tmp.Background = Brushes.LightSteelBlue;
tmp.BorderBrush = Brushes.Black;
tmp.BorderThickness = new Thickness(2);
tmp.Content = "血 量:" + HP.ToString() + '/' + maxHP.ToString();
lbTowerHP.ToolTip = tmp;
lbHP_BG.ToolTip = tmp;
}
示例6: 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);
}
示例7: Undefined
public Undefined(UndefinedV undefinedV)
{
InitializeComponent();
reference = undefinedV;
// listen to events from the controller
//ViewController.ViewEvents ...
// let the listener controller hear me :)
ViewController.ViewListener.Listen(this);
System.Windows.Controls.ToolTip toolTip1 = new System.Windows.Controls.ToolTip();
toolTip1.Content = "Click to Change";
this.ToolTip = toolTip1;
if ((reference.Reference.Parent as OperationD).Children.Count == 1)
{
// the undefined is the only item in this structure
// do not offer chance to be removed
rightClickMenu.Items.Remove(delete);
}
if ((reference.Reference.Parent.Parent as ChoiceD).Children.Count == 1)
{
// do not allow remove choice
rightClickMenu.Items.Remove(removeChoice);
}
}
示例8: AddFileToolBar
void AddFileToolBar(ToolBarTray tray, int band, int index)
{
ToolBar toolbar = new ToolBar();
toolbar.Band = band;
toolbar.BandIndex = index;
tray.ToolBars.Add(toolbar);
RoutedUICommand[] comm = {
ApplicationCommands.New, ApplicationCommands.Open, ApplicationCommands.Save
};
string[] strImages = {
"NewDocumentHS.png", "OpenHS.png", "SaveHS.png"
};
for (int i = 0; i < 3; i++)
{
Button btn = new Button();
btn.Command = comm[i];
toolbar.Items.Add(btn);
string fileName = Path.Combine(Directory.GetCurrentDirectory(), strImages[i]);
Image img = new Image();
img.Source = new BitmapImage(new Uri(fileName));
img.Stretch = Stretch.None;
btn.Content = img;
ToolTip tip = new ToolTip();
tip.Content = comm[i].Text;
btn.ToolTip = tip;
}
CommandBindings.Add(new CommandBinding(ApplicationCommands.New, OnNew));
CommandBindings.Add(new CommandBinding(ApplicationCommands.Open, OnOpen));
CommandBindings.Add(new CommandBinding(ApplicationCommands.Save, OnSave));
}
示例9: CreateHyperLink
/// <summary>
/// Tworzy linka i ustawia jego właściwości
/// </summary>
/// <param name="linkText"></param>
/// <param name="linkAdress"></param>
/// <param name="toolTip"></param>
/// <returns></returns>
private static Hyperlink CreateHyperLink(string linkText, string linkAdress, string toolTip, FontWeight weight,
Brush linkColor, RoutedCommand command)
{
System.Windows.Controls.ToolTip tip = new ToolTip();
tip.Content = toolTip;
tip.StaysOpen = true;
tip.Style = (Style) Application.Current.FindResource("YellowToolTipStyle");
Hyperlink hyperlink = new Hyperlink(new Run(linkText))
{
NavigateUri = new Uri(linkAdress),
TextDecorations = null,
FontWeight = weight,
//FontWeights.SemiBold,
Foreground = linkColor,
ToolTip = tip
};
hyperlink.Command = command;
hyperlink.CommandParameter = linkAdress;
ToolTipService.SetInitialShowDelay(hyperlink,700);
ToolTipService.SetShowDuration(hyperlink,15000);
//hyperlink.AddHandler(Hyperlink.RequestNavigateEvent,
// new RequestNavigateEventHandler(HyperLinkRequestNavigate));
return hyperlink;
}
示例10: ShowToolTip
private void ShowToolTip()
{
if (tooltip == null)
{
tooltip = new ToolTip();
tooltip.StaysOpen = true;
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1.5);
tooltip.PlacementTarget = Element;
tooltip.Placement = PlacementMode.Right;
timer.Tick += delegate
{
tooltip.IsOpen = false;
timer.Stop();
};
}
var list = ValidationService.GetErrors(Element);
if (list.Count == 0) return;
tooltip.Content = list.OrderBy(e => e.Priority).First().ErrorContent;
if (tooltip.Content != null)
{
tooltip.IsOpen = true;
timer.Start();
}
}
示例11: ColorGrid
public ColorGrid()
{
bord = new Border();
bord.BorderBrush = SystemColors.ControlDarkDarkBrush;
bord.BorderThickness = new Thickness(1);
AddVisualChild(bord);
AddLogicalChild(bord);
unigrid = new UniformGrid();
unigrid.Background = SystemColors.WindowBrush;
unigrid.Columns = xNum;
bord.Child = unigrid;
for (int y = 0; y < yNum; y++)
{
for (int x = 0; x < xNum; x++)
{
Color clr = (Color) typeof(Colors).GetProperty(strColors[y, x]).GetValue(null, null);
cells[y, x] = new ColorCell(clr);
unigrid.Children.Add(cells[y, x]);
if (clr == SelectedColor)
{
cellSelected = cells[y, x];
cells[y, x].IsSelected = true;
}
ToolTip tip = new ToolTip();
tip.Content = strColors[y, x];
cells[y, x].ToolTip = tip;
}
}
}
示例12: TooltipController
public TooltipController(UIElement element)
{
if (element == null)
throw new ArgumentNullException("element");
m_Element = element;
element.MouseEnter += new MouseEventHandler(element_MouseEnter);
element.MouseLeave += new MouseEventHandler(element_MouseLeave);
element.MouseMove += new MouseEventHandler(element_MouseMove);
m_AutoHideTimer = new Storyboard();
m_AutoHideTimer.Duration = new Duration(new TimeSpan(0, 0, 0, 5, 0));
m_AutoHideTimer.Completed += new EventHandler(m_AutoHideTimer_Completed);
m_TooltipTimer = new Storyboard();
m_TooltipTimer.Duration = new Duration(new TimeSpan(0, 0, 0, 1, 0));
m_TooltipTimer.Completed += new EventHandler(m_TooltipTimer_Completed);
m_ToolTip = new ToolTip();
m_ToolTip.Padding = new Thickness(0);
m_ToolTip.Opened += new RoutedEventHandler(m_ToolTip_Opened);
m_ToolTip.Closed += new RoutedEventHandler(m_ToolTip_Closed);
//m_ToolTip.VerticalOffset = 10;
//m_ToolTip.HorizontalOffset = 10;
}
示例13: 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;
}
示例14: Person
public Person(Canvas canvas, Graph graph, Point point, CurrentPerson cp, ToolTip tp)
{
image = new Image();
var img = new BitmapImage();
img.BeginInit();
img.UriSource = new Uri("pack://application:,,,/program_final;component/Resources/miku.gif");
img.EndInit();
ImageBehavior.SetAnimatedSource(image, img);
image.MouseLeftButtonUp += Person_MouseLeftButtonUp;
image.ToolTip = tp;
ToolTipService.SetInitialShowDelay(image, 0);
ToolTipService.SetShowDuration(image, 60000);
canvas.Children.Add(image);
Canvas.SetZIndex(image, 1);
point = graph.closestNode(point).getPoint();
Canvas.SetLeft(image, point.X - 16);
Canvas.SetTop(image, point.Y - 34);
this.location = point;
this.graph = graph;
this.canvas = canvas;
this.moving = false;
this.cp = cp;
}
示例15: ToolTipService
public ToolTipService(MapControl3D control)
{
m_control = control;
m_hoverTileView = control.HoverTileView;
m_content = new TileToolTipControl();
m_content.DataContext = m_hoverTileView;
var popup = new ToolTip();
popup.Content = m_content;
popup.Placement = System.Windows.Controls.Primitives.PlacementMode.Right;
popup.HorizontalOffset = 4;
popup.PlacementTarget = m_control;
m_popup = popup;
// Disable the animations, because we lose datacontext during fade-out animation.
// We need to override the default values in the PlacementTarget control
m_control.Resources.Add(SystemParameters.ToolTipAnimationKey, false);
m_control.Resources.Add(SystemParameters.ToolTipFadeKey, false);
m_control.Resources.Add(SystemParameters.ToolTipPopupAnimationKey, PopupAnimation.None);
this.IsToolTipEnabled = true;
m_control.GotMouseCapture += (s, e) => this.IsToolTipEnabled = false;
m_control.LostMouseCapture += (s, e) => this.IsToolTipEnabled = true;
}