本文整理汇总了C#中System.Windows.Controls.ToolTip.SetResourceReference方法的典型用法代码示例。如果您正苦于以下问题:C# ToolTip.SetResourceReference方法的具体用法?C# ToolTip.SetResourceReference怎么用?C# ToolTip.SetResourceReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ToolTip
的用法示例。
在下文中一共展示了ToolTip.SetResourceReference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateToolTipContent
void UpdateToolTipContent(IWpfTextViewLine line) {
IGlyphTextMarkerHandlerContext glyphTextMarkerHandlerContext = null;
foreach (var marker in glyphTextViewMarkerService.GetSortedGlyphTextMarkers(line)) {
if (glyphTextMarkerHandlerContext == null)
glyphTextMarkerHandlerContext = new GlyphTextMarkerHandlerContext(wpfTextViewHost, margin, line);
var toolTipInfo = marker.Handler.GetToolTipContent(glyphTextMarkerHandlerContext, marker);
if (toolTipInfo != null) {
Debug.Assert(toolTip == null);
toolTipMarker = marker;
toolTip = new ToolTip();
PopupHelper.SetScaleTransform(wpfTextViewHost.TextView, toolTip);
var toolTipContentString = toolTipInfo.Content as string;
if (toolTipContentString != null) {
toolTip.Content = new TextBlock {
Text = toolTipContentString,
TextWrapping = TextWrapping.Wrap,
};
}
else
toolTip.Content = toolTipInfo.Content;
var toolTipStyle = toolTipInfo.Style as Style;
if (toolTipStyle != null)
toolTip.Style = toolTipStyle;
else
toolTip.SetResourceReference(FrameworkElement.StyleProperty, toolTipInfo.Style ?? "GlyphTextMarkerToolTipStyle");
toolTip.Placement = PlacementMode.Relative;
toolTip.PlacementTarget = margin.VisualElement;
toolTip.HorizontalOffset = 0;
toolTip.VerticalOffset = toolTipLine.TextBottom - wpfTextViewHost.TextView.ViewportTop + 1;
toolTip.IsOpen = true;
return;
}
}
}
示例2: ShowToolTip
void ShowToolTip() {
if (session.IsDismissed)
return;
var completionVM = control.completionsListBox.SelectedItem as CompletionVM;
if (completionVM == toolTipCompletionVM)
return;
HideToolTip();
if (completionVM == null)
return;
var container = control.completionsListBox.ItemContainerGenerator.ContainerFromItem(completionVM) as ListBoxItem;
if (container == null || !container.IsVisible)
return;
var toolTipElem = TryGetToolTipUIElement(completionVM);
if (toolTipElem == null)
return;
// When the tooltip was reused, it was empty every other time, so always create a new one.
toolTip = new ToolTip {
Placement = PlacementMode.Right,
Visibility = Visibility.Collapsed,
IsOpen = false,
};
toolTip.SetResourceReference(FrameworkElement.StyleProperty, "CompletionToolTipStyle");
// There's a scrollbar; place the tooltip to the right of the main control and not the ListBoxItem
var pointRelativeToControl = container.TranslatePoint(new Point(0, 0), control);
toolTip.VerticalOffset = pointRelativeToControl.Y;
toolTip.PlacementTarget = control;
toolTip.Content = toolTipElem;
toolTip.Visibility = Visibility.Visible;
Debug.Assert(!toolTip.IsOpen, "Can't set the tool tip's LayoutTransform if it's open");
PopupHelper.SetScaleTransform(wpfTextView, toolTip);
toolTipCompletionVM = completionVM;
toolTip.IsOpen = true;
}
示例3: TextView_MouseHover
void TextView_MouseHover(object sender, MouseEventArgs e)
{
var info = refFinder.GetReference(e);
if (info == null || info.Value.Language == null || info.Value.Reference == null)
return;
var ttContent = codeToolTipManager.CreateToolTip(info.Value.Language, info.Value.Reference);
if (ttContent == null)
return;
Close();
toolTip = new ToolTip {
Content = ttContent,
IsOpen = true,
};
toolTip.SetResourceReference(FrameworkElement.StyleProperty, "CodeToolTip");
}