• Winform中调用WPF控件


    有两种调用方式,在使用之前都将控件“ElementHost”添加到 Form 中:

    方式一:

    直接声明wpf中控件(使用 Windows.Controls)

    Public Class Form1
        Dim txt As Windows.Controls.TextBox = New Windows.Controls.TextBox()
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load        
    txt.SpellCheck.IsEnabled = True ElementHost1.Child = txt End Sub End Class

    方式二:

    首先新建一个 ”User Control“,

    之后,如下编辑“UserControl1.xaml”中的内容:

    <Grid>
        <TextBox x:Name="textBox" Foreground="Black" FontSize="24" Margin="0"></TextBox>
        <TextBox SpellCheck.IsEnabled="True" />
    </Grid>

    最后,修改”Form1.vb“代码如下:

    Public Class Form1
        Private uc As UserControl1 = New UserControl1()
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            ElementHost1.Child = uc
        End Sub
    End Class

    结果如下所示:

  • 相关阅读:
    HNOI 2006 BZOJ 1195 最短母串
    BZOJ 3029 守卫者的挑战
    Codeforces 401D Roman and Numbers
    ZJOI2010 数字计数
    BZOJ 3329 Xorequ
    Codeforces 235 C
    SPOJ 8222 Substrings
    BZOJ 1396 识别子串
    (模板)归并排序
    poj3122 Pie (二分)
  • 原文地址:https://www.cnblogs.com/jizhiqiliao/p/10245390.html
Copyright © 2020-2023  润新知