We have some code that we tried out on a WPF project in .net 4.0 and it worked with using Windows but we re started the project to combine everything together and now we have started to take advantage of the UserControls. My Window that worked with my previous code doesn't work with this new UserControl code and it says what I posted in the title.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfPrototype1Screens
{
/// <summary>
/// Interaction logic for Screen_1.xaml
/// </summary>
public partial class Screen_1 : UserControl
{
public Screen_1()
{
this.InitializeComponent();
}
protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
{
base.OnMouseDoubleClick(e);
FrameworkElement element = e.OriginalSource as FrameworkElement;
if(element.DataContext is DateTime){
DateTime date = (DateTime) element.DataContext;
WpfPrototype1Screens.Add_Event addEvent = new Add_Event(date);
addEvent.Show();
addEvent.Focus();
}
}
}
}
The problem comes in the last 2 lines of the OnMouseDoubleClick event method. Focus shows up as fine, but addEvent.Show(); doesn't. It says that there is no such thing as Show() for this type of Usercontrol. Now I have found out that there are different usercontrols... there is the one that I tried to reference by (right clicking --> adding reference --> .Net tab --> and selecting System.Windows.Forms();... but that didn't work because I realized that the UserControl that we are using is not a "forms" usercontrol, it is a Usercontrol control? i guess? I do not know what to do to make this code compile and work