k3nnt0ter0
Member
- Joined
- Sep 6, 2012
- Messages
- 7
- Programming Experience
- Beginner
I embedded the WPF to vb.net and I got some error.
1. There's still a green underline on line
but that's nothing I guess since the underline was green.
2. My very problem is on the line
says
My guess is that, it was suppose to be hosted on a Window but in my project's case, it was hosted on an Elementhost
Here's the code :
1. There's still a green underline on line
C#:
Me.SampleUserControl1 = New SampleWpfUserControlLibrary.SampleUserControl()
2. My very problem is on the line
C#:
_hostWindow.OpenDocument();
Object reference not set to an instance of an object.

My guess is that, it was suppose to be hosted on a Window but in my project's case, it was hosted on an Elementhost
Here's the code :
C#:
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
namespace SampleWpfUserControlLibrary
{
/// <summary>
/// Interaction logic for SampleUserControl.xaml
/// </summary>
public partial class SampleUserControl
{
private IApplicationHostWindow _hostWindow;
[Obsolete("This constructor should not be used", false)]
public SampleUserControl()
{
InitializeComponent();
}
public SampleUserControl(IApplicationHostWindow applicationHostWindow)
{
_hostWindow = applicationHostWindow;
I****TestVisible = true;
InitializeComponent();
}
public double GetViewboxWidth()
{
return viewHost.ActualWidth;
}
public double GetViewboxHeight()
{
return viewHost.ActualHeight;
}
public void SetViewboxChild(UIElement child)
{
viewHost.Content = child;
}
public void ProcessLeftButtonDown(Point point)
{
var result = VisualTreeHelper.HitTest(this, point);
return;
}
protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
{
return base.HitTestCore(hitTestParameters) ??
new PointHitTestResult(viewHost.Content as Visual ?? viewHost, hitTestParameters.HitPoint);
}
private void exitMenuItem_Click(object sender, RoutedEventArgs e)
{
_hostWindow.Exit();
}
private void newProjectMenuItem_Click(object sender, RoutedEventArgs e)
{
_hostWindow.OpenDocument();
}
private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
return;
}
private void UserControl_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
return;
}
}
}