Monday, October 10, 2011

Creating a WPF Web Application

I had a LOT of trouble getting anything working. This will help avoid future pitfalls.
I started by opening a new application:
Visual C# –> Windows –> WPF Browser Application.
Next, I tried to add a WPF Window. WRONG! I should have added a WPF Page. They are very similar, but a WPF Window would not work. I named the page Trans_Main.xaml.
At this point, the project was set up to run Page1.xaml. To change this, I went into the App.xaml file and corrected the StartupUri parameter.
This worked on IE, but when I tried to run it on Chrome, it reported that I was missing a Plug In.
I also noted that the Debug tab in the Project Properties window lets us select the Start Action. I had hoped that I could set this to Trans_Main.xaml, but this did not work. I had to set it to …bin\Debug\Translate.xbap. In fact, double clicking this file would bring up the Trans_Main.xaml file, but double-clicking the Trans_Main.xaml file directly caused an error.
I tried eliminating x:Class="Translate.Trans_Main"  from the XAML file. After that, IE would open and display the file.  I put the line back and copied the EXE file to the bin directory and this seemed to work. I tried setting the program to build directly to the bin directory (instead of bin\debug), but this seemed to mess things up. I did not play with it for long enough to figure out why.
Bottom line is that this technology is OK for use with Internet Explorer, but not for other browsers. I guess I will stick to using WPF for Applications only.
(Note to self: See the project in c:\wwwroot\inetpub\Translate)

No comments:

Post a Comment