October 16, 2008 12:44 PM
Posted by: MarkWPF
WPFFirstly, what is a resource?
In the world of WPF, it means two things:
- an assembly resource
- an object resource
An assembly resource is a blob of data that has been embedded in your assembly. Examples are images, videos or sounds.
An object resource is slightly different. It specifies a re-usable chunk of information, but is a .Net framework object instead.
In the WPF world, that means defining things like styles.
It also means being able to re-use those chunks in different areas of your program.
October 13, 2008 1:59 PM
Posted by: MarkWPF
WPFIt would seem that Silverlight 2 (WPF on the web!) is getting closer and closer.
It’s very exciting of course, simply because having WPF on the web makes it more available to more people.
Microsoft have released an RC (Release Candidate) for the development world, allegedly to allow everyone to get their sites working against the final release API.
Personally, i think it’s to get the development world licking their lips at the features being included.
That works for me without a doubt
September 30, 2008 11:18 AM
Posted by: MarkWPF
WPF,
XAML,
XbapWhen you are using pages as your building blocks for WPF development, hyperlinks are a useful way to move onto different pages.
That has been proved of course on the internet for many years
As to why you might use pages, see a previous blog.
A hyperlink in the xaml world is similar to the anchor tag in html, in the respect that it goes inside relevant other tags.
For example, to add a hyperlink to a textblock, specify the hyperlink inside the textblock:
<TextBlock>My test is going to be <Hyperlink NavigateUri=”chelsea.xaml”>chels</Hyperlink> and their lack of Deco
</TextBlock>
That specifies the hyperlink, and when you click on it the NavigationService will move to the chelsea.xaml page
September 29, 2008 4:22 PM
Posted by: MarkWPF
WPF,
XAML,
XbapWith a standard WPF application, you don’t really have many options as to how you display the application – it has a top level window and that’s it.
With a WPF application, you have four options on how to display your top level page in a container:
- Using a NavigationWindow – which gives you functionality akin to a normal WPF Window
- U1sing a Frame directly inside the browser, also called an Xbap or browser application
- Using a Frame inside another window
- Using a Frame inside another page
These all have slightly different advantages, and I have done a description for each:
- Hosting in NavigationWindow.
- Hosting a frame directly inside the browser
- Hosting a frame inside a window
- Hosting a frame nested inside another frame
September 29, 2008 4:21 PM
Posted by: MarkWPF
WPF,
XAML,
XbapFor a description of what a page is see blog post.
Why would you want to place a page within the browser?
It means you can run the WPF application over the internet or an intranet without any installation at all.
Thus far,I’ve mainly seen browser applications used as demos.
You create one using the visual studio new wpf browser application template.
What is useful though, is that you can write all your views (or dialogs) as pages by using the <page> xml construct.
Then you can put them into a class library (dll to us old-uns).
That enables you to have one project that is a WPF application, and one browser application both references the common class library.
Both types of application can reference the pages, and bingo you maintain your ui logic in one place.
September 27, 2008 5:15 PM
Posted by: MarkWPF
WPF,
XAML,
XbapWhat do I mean by that?
Simply put, you can embed a page within another page.
Why would you want to do that?
It allows re-use for a start, as well as splitting functionality down into logical chunks.
In the following example, I have done just that:
First the top level window
<Window x:Class=”BlogSept.Window1″
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
Title=”Window1″ Height=”300″ Width=”300″>
<Grid>
<Frame Source=”page1.xaml” NavigationUIVisibility=”Visible”>
</Frame>
</Grid>
</Window>
Then page1
<Page x:Class=”BlogSept.Page1″
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
Title=”Page1″>
<Grid>
<Rectangle Margin=”46,68,54,132″ Name=”rectangle1″ Stroke=”Black” Fill=”Chocolate” OpacityMask=”Beige” Opacity=”0.6″ />
<TextBox Text=”Random text” Margin=”80, 190, 10, 10″ />
<Frame Source=”page2.xaml” />
</Grid>
</Page>
Notice how it embeds a copy of page2 inside it’s visual tree.
Here is page 2:
<Page x:Class=”BlogSept.Page2″
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
Title=”Page2″>
<Grid>
<Ellipse Margin=”42,71,64,118″ Name=”ellipse1″ Stroke=”Black” Fill=”BlueViolet” />
</Grid>
</Page>
September 26, 2008 1:56 PM
Posted by: MarkWPF
WPF,
XAML,
XbapFor an explanation of what an Xbap is, look at a previous blog of mine.
With Xbap pages, you have a useful resource.
You can host pages within other windows or with a special xaml construct – a frame.
To do this simply declare the frame within a window:
if page1.xaml contains a page of further xaml, it’s contents will be displayed in the window
September 24, 2008 1:22 PM
Posted by: MarkWPF
WPF,
XAML,
XbapTo hosting your page in a NavigationWindow, what do you need to do?
Well, not a lot actually.
You write your page, set your app.xaml’s startup uri to point to your page and run it!
It will appear in a browser if you created a browser application, or inside a NavigationWindow if it is a WPF application.
The WPF application will create a NavigationWindow instead of a Window to act as the top level container.
It also uses the page’s WindowTitle property for the caption in the NavigationWindow
The NavigationWindow class derives from Window and adds the navigation buttons and the navigation service for you.
September 23, 2008 3:55 PM
Posted by: MarkWPF
WPF,
XAML,
XbapFor an explanation of what an Xbap is, look at a previous blog of mine.
I have spent the last few weeks writing a Xbap (or page navigation) application in WPF.
The first thing you have to get used to is that you need to forget Windows, everything is in terms of pages.
What is a page?
Actually it looks stunningly similar to a WPF Window.
You get to use exactly the same xaml markup constructs, dockpanels, textboxes etc etc.
The advantage of Xbaps over normal WPF application is that they run in the browser (firefox as well as internet explorer) and yet you still get all of the great WPF goodies, including animations and styles.
The only restrixtion is that they need to run under partial trust rather than full trust.
What does that mean in practice?
It means that whatever zone you pick for your xbap application confines its functionality.
For example, an internet zone xbap cannot access the local file system or the registry – which is only logical