TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Marvin Pereda
NA
1
1.3k
Could you help me to embed C#WPF to VB.NET?
Oct 10 2012 10:47 PM
using System;using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
"SampleUserControl.xaml.cs"
namespace SampleWpfUserControlLibrary
{
/// <summary>
/// Interaction logic for SampleUserControl.xaml
/// </summary>
public partial class SampleUserControl
{
private IApplicationHostWindow _hostWindow;
public SampleUserControl()
{
InitializeComponent();
}
[Obsolete("This constructor should not be used",false)]
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;
}
}
}
"IApplicationHostWindow.cs"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SampleWpfUserControlLibrary
{
public interface IApplicationHostWindow
{
void OpenDocument();
void Exit();
}
}
What I did as off now is I added the WPF to VB.Net. As I run the program, an error occurs being null of _hostWindow.
http://i46.tinypic.com/mrpxi.png
on the line
_hostwindow.OpenDocument();
says "Object reference not set to an instance of an object"
It seems to work fine when I run the WPF only
http://i45.tinypic.com/oppylf.png
Reply
Answers (
0
)
C# obtain return code from called program
C# linq nullable object