XBAPs Part 1: An introduction to this Gem
Join the DZone community and get the full member experience.
Join For Freeintroduction
xbaps (xaml browser application) are a really cool feature that was
introduced in .net 3.0 together with wpf. well you can say that xbaps
are as such part of wpf because at the end of the day xbaps are just
wpf applications that can run inside the browser. one important thing
to state here is that xbaps and silverlight have nothing to do with
each other. xbaps are full .net enabled wpf applications, while
silverlight is a “cut down version of wpf” that runs as a browser
plugin. in order to run a silverlight enabled website you need to
download the silverlight installer(that is really really small approx
4.3 mb), if you want a client to run a xbap the client has to have .net
installed on his machine (the full .net or
client profile
).
before we continue i would like to point out that this post is just
an introduction to xbaps. i will have part 2, part 3 and part x that
should be much more interesting to follow…. yet if you never heard of
xbaps you should continue reading this post (and try not to fall asleep
).
what does your client need?
as i said above, in order for a client to run your xbap he/she needs to have .net framework installed. it’s as if the client is going to run a windows application. xbaps got a set of improvements in .net 3.5 such as support for firefox ( read more here ) and also support for consuming wcf service in partial trust mode (with some limitations of course but still it’s good, read more here ). so yea if you are planning on using xbap’s i would seriously consider .net 3.5.
to summarize your client needs to have .net installed and he can use the xbap in internet explorer or if he prefers (and you are using .net 3.5) firefox.
some things to keep in mind …
xbaps run in the browser and give an impression of being a normal website (super cool website i must say
) while instead they are just actual apps that never jump out of the
browser, yet there is more to it… xbap’s run in a “sandbox”, basically
they run as
partial trust
by default. what this means is that some of the things that you would
assume would work in a wpf app would not work in an xbap, for example
reflection (and also the
new 3.5 sp1 feature effects
). of course there are workarounds. you can run xbaps as full trust mode and we will discuss how to later on in this article.
building a simple xbap
so let’s start having a look at how one can build an xbap. in order to create a new xbap project you have to do the usual stuff, so go to file > new > project and select wpf browser application
now that we created the project, let’s have a look at what visual studio created for us
so as you can see by default visual studio created more or less the same stuff it would have created for a wpf application yet instead of using a window it created a page. this is very important because a page was designed for navigation (the back and forward button of the browser). i will discuss navigation more later on in this article. besides this visual studio also created a pfx file. the pfx file is a way how to sign the exe, by default visual studio creates a pfx file that it uses to sign the click once installer for the xbap.
the image above shows how visual studio generated that pfx file. please not that there is the computer name and username inside the pfx files (which obviously is not something you want to give to your client). charles perzold discusses this in more detail here .
ok so now that we know what visual studio created for us (thanks vs
we love you) we can test our xbap app (yea we can already run it
). in order to see something on screen lets just create a button in the page1.xaml and press f5 to run.
<button content="my first xbap :) " height="50" width="150"/>
yahhooo we have everything figured out don’t we
well there are a couple of other things we need to have a look at.
conclusion
if you are a wpf developer you will be developing xbap in no time. there are a couple of things you must keep in mind, like code access security and other tricks like how to consume wcf service…. in my next posts i will cover these things and make sure that i pass on my knowledge (knowledge that came from a lot of frustration and hours of head banging on the table).
Published at DZone with permission of Marlon Grech. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Apache Kafka vs. Message Queue: Trade-Offs, Integration, Migration
-
Build a Simple Chat Server With gRPC in .Net Core
-
Playwright JavaScript Tutorial: A Complete Guide
-
Front-End: Cache Strategies You Should Know
Comments