Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Edit Content in Winform ElementHost

$
0
0

Hi all

I hope someone can help me to understand ..

In my example i have a winform + elementhost 

If i try to add some object into elementhost it doesn't work and nothing happens

However if i add some ojerct into elementhost in sub New() it work perfectly and i can see in my winform.

Why? 

This is an example:

XAML

<UserControl x:Class="UserControl1"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"><Grid x:Name="GrigliaTest"></Grid></UserControl>

VB XAML

Imports System.Windows.Controls

Public Class UserControl1
    Public Sub New()

        ' Chiamata richiesta dalla finestra di progettazione.
        InitializeComponent()

        ' Aggiungere le eventuali istruzioni di inizializzazione dopo la chiamata a InitializeComponent().

    End Sub
    Public Sub AddButton()
        Dim Btn As New Button
        Btn.Height = "50" : Btn.Width = "50" : GrigliaTest.Children.Add(Btn)
    End Sub
End Class

VB FORM

Imports WindowsApplication1.UserControl1

Public Class Form1
    Public Prova As New WindowsApplication1.UserControl1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Prova.AddButton()
    End Sub
End Class

IlCasti


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>