« WindowShade X for Mac OS X | Main | MSDN Ready To Launch 2005 »

WPF / Avalon is so cool ...

I'm going to work on this ... but I wanted to do it in steps. Essentially a rich text box with a cool interactive, in-line, combo-box. First step is to make the basics work with a simple data binding.

Try doing this in Win32 programming!

<Grid.Resources>
	<ResourceDictionary>
		<XmlDataProvider x:Key="ListDS" 
		Source="Data.xml" d:IsDataSource="True"/>
	</ResourceDictionary>
</Grid.Resources>
<ColumnDefinition/>
<RowDefinition/>
<RichTextBox x:Name="myRichTextBox" Margin="88,98,210,126"
	Width="Auto" Height="Auto" 
	RenderTransformOrigin="0.5,0.5">
	<FlowDocument AllowDrop="True" IsEnabled="False" 
	IsHyphenationEnabled="False">
	<Paragraph><Run>This is so cool. A combo box 
		floating in the text region of the rich 
		text control.</Run>
	<InlineUIContainer>
	<ComboBox IsSynchronizedWithCurrentItem="True" 
	x:Name="embeddedCombo" 
	RenderTransformOrigin="0.5,0.5" 
	Width="150" Height="23" IsEnabled="True" 
	DataContext="{Binding Source={StaticResource ListDS}, XPath=/List/ListItem, Mode=Default}" 
	ItemsSource="{Binding Source={StaticResource ListDS}, XPath=/List/ListItem, Mode=Default}" 					
	SelectedValuePath="{Binding XPath=/List/ListItem, Mode=Default}" />
	</InlineUIContainer></Paragraph>
	</FlowDocument>
</RichTextBox>

TrackBack

Listed below are links to weblogs that reference WPF / Avalon is so cool ...:

» WPF and Rich Content Model from Rob Relyea
Doing my feedster search for WPF, I found a post where Aaron was excited about embedding a combo box inside a textbox. He has a picture of it in action. One key developer benefit of WPF is... [Read More]

Comments

I just fixed my entry too .. I had source code, but it had gotten embedded as XML directly, rather than formatted for viewing and reading!

Hey dude, I cannot believe you guys take this WPF / Avalon / .NET Mutation stuff *seriously*. Which means you do _not_ have hundreds of thousands or millions of lines of code to maintain, that actually still does its job, creates revenues and gets things done. One of the biggest companies that does NOT rely on .NET for their cash-cow applications are Microsoft themselves. Truth is, Microsoft doesn't need you: the ISV, and would much rather take over your business niche. Mutating the technical foundation on a 3 year basis is one solid way of achieving this. Microsoft is trying to deprecate the C API, which is just a bold thing to do and also very intelligent. Create an somehow efficient non-C layer above windows and make other people use only this layer. Breaking code all over the place while entertaining the bloggish techie community, then change the layer by utilizing the latest �modern technology� (xml based crap for a combobox) every now and then, while still using the real efficient API yourself and venturing into new markets. Time to buy some Microsoft stocks.

Hey Brain,

Thanks for the comments. Actually, the company I work for has many millions lines of existing code not in any managed lanaguage. It does its job, creates revenues, and actually gets quite a lot done. So, clearly, that statement isn't accurate.

Microsoft has many applications written in .NET. Is the amount of .NET code comparable to the amount that is not today at Microsoft? Certainly NOT. But things are moving that way. Many of their newer server products are for example. Lots of Visual Studio. The .NET Framework. ASP.NET. Etc. Much of Avalon/WPF is written in managed code. Not all. But not zero.

I don't think Microsoft's business plan was: "Entertain the bloggish techie community." Can't make much money on that.

If you don't see that this is a revolutionary change, and a positive one over the long haul, then you just don't get it. Short term, there will be some pain. Go ahead and stay where you are and let the competition pass you by -- or you can be the guy who's maintaing the old crappy Win32 C code. The world will need some of them I suppose. Have fun.

OK,

a) For the consulting software industry (you create apps that solve problems in your customers specific domain, interacting with existing applications) .NET works perfectly: Create the usual GUI frontend talking to a database backend. Point taken. Much easier than C/C++ (MFC being a mess, arguably with a non-braindead toolkit such as qt i do not agree). Database access with .NET is excellent (but of course excells only with microsoft db backends), COM+ is extremeley easy to use now - Serviced Components and is a very performant middle-thier layer). For the consultant software industry .NET kills Java at the client side (Where java actually never stood) and is a real opposition to java on the server side, for standalone servers, software interacting with windows software and microsoft servers). OK, point taken. .NET is a great platform for this niche.

b) but not for the enduser ISV shrinked-wrap software market, that promises the highest revenues once you actually have reached a certain level (and have survived). Even though arguably the whole momentum of the software market is slowing down to some degree, your software must a) be able to survive for at least a decade b) should be vender independant. With the old C this is no problem because you can use C++ and wrappers above the native api. Every native OS api was C. thats how oracle succeeded. ALL apps that are successfull across platforms run like this. Photoshop, whatever. because at the end you program to a C API and you can encapsulate this...

But with .NET you no longer have a stable foundation. There will be a time where no one has a C API See this Avalon framework .. what a crap? do you think internally microsoft uses such an idiotic api? so we had win32, now .net, now the presentation framework. There will come a time where microsoft will no longer ship a platform sdk and the real api will be totally closed and reserved for microsoft only. do you really think this avalon crap is anything thats industrial quailty software?
Write a robust client with this technology?

Again, .NET is productive, but VB6 wasn't unproductive either, people lost 100% of their codebase and their products when betting on VC6, C++ apps still run. Now Microsoft closes the C API and creates an idiotic api every third year?

or do you *really* think your example in this post is anything thats comparable to the power of old (stinking?) win32 GDI? GDI is so boring we just need something new, right?

Writing end-user software for the windows platform that can remain technically stable for at least one decade is nearlly impossible now.

Errata:

"when betting on VC6"

VB6

The company I work for -- which is an ISV actually, has one smaller product underway which will use WPF. It's a small application so we can learn the ropes.

What "idiotic" APIs are you referring to? Microsoft of course will use the same APIs. They were banged up about that several years ago by the government -- no more 'private/internal' APIs. Using Reflector or something similar, it's not hard to see what's actually driving this technology and where there are 'private' or internal methods. The power of .NET though it that it's hard to make an internal only API available outside of a single assembly without exposing it to everyone.

Yes, I think this simple example demonstrates a capability I've never had before. And honestly, yes, it's something I would use for the applications the company I work at writes. It's not the norm of course, but it demonstrates something that I couldn't fathom trying to do in Win32. Have you done owner drawn code before? Have you tried to stylize an application? Have you tried to do those in Win32? I have. YIKES! It's a pain in the butt! The amount of work necessary in Win32 is incredible. It never ceases to amaze me how difficult it is to write a nice stylized button for example. There are so many issues to consider. Or worse, a treeview!

What is the non-stable platform you refer to?

I want technology to progress. I don't want to stick back with C anymore. It's not good enough to grow the power of computers. Web 2.0 isn't it. These PCs sitting under most peoples desks (or laptops) are generally under utilized. Win32 isn't the technology to push them harder. Is Win32 boring? No. Is it overly difficult to write a good 'modern' application. Absolutely. Something needed to be done.

MS needs to start fresh. Apple did the same thing. Linux probably will at some point when they realize they can't have multiple tracks with different standards if they ever want to catch up.

Win32 isn't going away completely. It just won't be improved much anymore. C programmers will be writing games for example for many many years.

ITs a new market. Technology is a driving market and this is a new level to that in the RIA field. IT has some interesting things going on and its fun, satisfy developers and the product will make it. Progression means change and markets, take advantage of it or watch others.

Ryan -- yep.

Help support my web site by searching and buying through Amazon.com (in assocation with Amazon.com).