I embedded the WPF to vb.net and I got some error.
1. There's still a green underline on linebut that's nothing I guess since the underline was green.Code:Me.SampleUserControl1 = New SampleWpfUserControlLibrary.SampleUserControl()
2. My very problem is on the linesaysCode:_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 :
It works fine when I run the WPF only. . But when I add it on the VB Project, error occursCode: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; IsHitTestVisible = 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; } } }
![]()



Reply With Quote
Bookmarks