C# 使用工具提示显示在wpf中动态创建inkcanvas类
我想创建一个具有工具提示显示的多个inkcanvas。因此,我想动态创建ink canvas类。每当我创建inkcanvas类的实例时,必须在WPF窗口中创建一个具有工具显示的新ink canvasC# 使用工具提示显示在wpf中动态创建inkcanvas类,c#,wpf,xaml,C#,Wpf,Xaml,我想创建一个具有工具提示显示的多个inkcanvas。因此,我想动态创建ink canvas类。每当我创建inkcanvas类的实例时,必须在WPF窗口中创建一个具有工具显示的新ink canvas class1 mycanvas1 = new class1(" aa"); class1 mycanvas2 = new class1("bb") 字符串中的字母是工具提示显示的文本。你能告诉我怎么走吗。 我创建了一个工具提示为空文本的ink canvas use
class1 mycanvas1 = new class1(" aa");
class1 mycanvas2 = new class1("bb")
字符串中的字母是工具提示显示的文本。你能告诉我怎么走吗。
我创建了一个工具提示为空文本的ink canvas usercontrol。但我无法用上述方式调用此wpf用户控件。这里是我的代码
namespace strokecollectio
{
class mycan : InkCanvas
{
public mycan()
{
this.Width = 300;
this.Height = 200;
}
}
}
带有工具提示的InkCanvas自定义类:
[DebuggerDisplay("[{Scene}]Strokes:{Strokes.Count}, Children:{Children.Count}")]
public class InkCanvas_SandeepJadhav : InkCanvas
{
public InkCanvas_SandeepJadhav(string toolTip)
{
ToolTip = toolTip;
}
}
Inkcanvas类是动态创建的
public partial class MainWindow : Window
{
public InkCanvas_SandeepJadhav currCanvas = null;
double width = 0, height = 0, toolWindowHeight = 0;
public MainWindow()
{
InitializeComponent();
this.WindowState = System.Windows.WindowState.Maximized;
width = System.Windows.SystemParameters.WorkArea.Width;
height = System.Windows.SystemParameters.WorkArea.Height;
currCanvas = new InkCanvas_SandeepJadhav("Sandy");
currCanvas.Width = width;
currCanvas.Height = height - 150;
currCanvas.Background = (System.Windows.Media.Brush)new SolidColorBrush(Colors.Lime);
toolWindowHeight = (height / 10);
currCanvas.Margin = new Thickness(0, 0, 0, toolWindowHeight);
myGrid.Children.Add(currCanvas);
}
}
XAML代码
<Window x:Class="WpfMultiInkCanvas.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="myGrid"></Grid>
</Window>