In an earlier FAQ entry, I talked about how you can show a previously closed Windows Forms form. Well the same holds true for a WPF window and for the same underlying reason. When you close a WPF window, the native window is closed and destroyed. So trying to re-show it will just throw an [...]
Entries Tagged as 'WPF (Avalon)'
FAQ: Cannot reuse closed WPF windows
June 18th, 2010 · No Comments
Tags: FAQ · WPF (Avalon)
Article: Handling a Window’s Closed and Closing events in the View-Model
April 16th, 2010 · No Comments
This article discusses an attached behavior that lets you handle the View Window’s Closed and Closing events via commands in the View-Model. It was inspired by Reed Copsey, Jr.’s Blend behavior which is up on the Expression Code Gallery. Reed’s behavior uses a neat technique that lets the View-Model handle the Closing/Closed events of the [...]
Tags: C#/.NET · WPF (Avalon)
Article : EXIF Compare Utility using WPF
April 12th, 2010 · No Comments
The Exif Compare Utility is a WinDiff equivalent for image files that compares the Exif meta-data and displays the differences and similarities. The application is written using WPF and MVVM, and also makes use of my ExifReader library. In the article I briefly explain how to use the application and also discuss some of the [...]
Tags: C#/.NET · WPF (Avalon)
Correction for the instant binding attached behavior for WPF TextBoxes
April 8th, 2010 · 1 Comment
A few days back, I had blogged about an attached property I wrote to force instant binding in a WPF TextBox. Well it turns out I was having a “duh” moment there and this was pointed out to me very politely by Richard Deeming (a fellow CodeProject author). Turns out all I needed to do [...]
Tags: WPF (Avalon)
Article : An MVVM friendly approach to adding system menu entries in a WPF application
April 5th, 2010 · No Comments
The majority of MFC apps have always had an About… menu entry in the main window’s system menu, and this was primarily because the App Wizard generated code for that by default. I wanted to do something similar in a WPF application I’ve been working on, and I wanted to do it in an MVVM [...]
Tags: C#/.NET · WPF (Avalon)
An attached behavior for WPF TextBoxes to force instant binding
April 3rd, 2010 · 3 Comments
Update – Apr 9, 2010 You do not need to do all this – instead you just need to set UpdateSourceTrigger on the Binding to PropertyChanged. I’ve made an updated blog entry on this here : Correction for the instant binding attached behavior for WPF TextBoxes Original entry follows for posterity The default behavior for [...]
Tags: C#/.NET · WPF (Avalon)
Article : An extensible ExifReader class with customizable tag handlers
March 30th, 2010 · No Comments
I needed an Exif reader class for a C# application I was working on, and though I found quite a few implementations available including a few on The Code Project, none of them fully suited my requirements. So I wrote my own class. The article describes the use and implementation of this class, and also [...]
Tags: C#/.NET · WPF (Avalon)
An attached behavior for TextBoxes to support TextChanged commands
March 22nd, 2010 · 1 Comment
Recently I was working on an MVVM demo for an article where I wanted live filtering based on the contents of a text box. The problem with this is that the TextBox does not have a Command property, and thus I’d need to use code-behind to proxy its text changed event to the ViewModel. And [...]
Tags: C#/.NET · WPF (Avalon)
WPF : Opaque child windows on a transparent parent background
July 14th, 2008 · 3 Comments
If you set a parent window’s Opacity, any child windows can only have an opacity equal to or below the parent window’s. So if you want to keep the main window background transparent but leave the child controls (such as a text box) fully opaque, it will not work as you expect. One solution (there [...]
Tags: WPF (Avalon)
Article : Using data selectors to create a listbox with expand/collapse support
December 27th, 2007 · No Comments
After a brief gap I have decided to get back to writing articles. The following article demonstrates how to use data template selectors and also how to create a hierarchical listbox with expand/collapse support :- Using data selectors to create a listbox with expand/collapse support
Tags: WPF (Avalon)
WPF tip : Using a custom title bar
October 27th, 2007 · 3 Comments
While you can always custom paint the windows title bar, in most cases it ends up being a very messy approach with possible side effects. What I do in WPF is to disable the title bar in the window by setting its WindowStyle to none. <Window x:Class=”…” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” … MinWidth=”700″ WindowStyle=”None” Icon=”…”> I then [...]
Tags: WPF (Avalon)
A generic function to find a visual child from a visual tree
August 7th, 2007 · 2 Comments
Here’s a simple function you can use to get a specific child from a given visual tree. For example, you may want to get a handle to the scrollviewer in a listbox control. Here’s how you’d use the function to do that :- ScrollViewer scrollViewer = FindChildControl<ScrollViewer>(searchResultsListbox); And here’s the function listing :- private T [...]
Tags: WPF (Avalon)
Setting FontSize programmatically
July 29th, 2007 · 2 Comments
I was moving a WinForms app to WPF and I was perplexed for quite a while this morning when I found that setting the FontSize on a WPF TextBlock didn’t really give me the font-size I expected (the one that WinForms gave me). It was obvious pretty soon that WinForms was using point as the [...]
Tags: WPF (Avalon)
ShowDialog and centering the window
September 9th, 2006 · 2 Comments
I was using ShowDialog to show a Xaml window and was surprised to find that it wasn’t easy to get it to center on the calling Window. Setting the WindowStartupLocation property to CenterOwner did not seem to have much effect. That’s when I realized that the Owner has to be explicitly set. Now, I was [...]
Tags: WPF (Avalon)
Setting default focus to a particular control via XAML
July 7th, 2006 · 2 Comments
I wanted to avoid calling control.Focus() in the Window derived class’s constructor and wanted to see how it’s done via XAML. I couldn’t get it working after 5-10 minutes of trying out various stuff, but someone helped me out in the MSDN forums. Here’s how it’s done – in the following code snippet, I am [...]
Tags: WPF (Avalon)
Examination of a simple C# based Xaml app
May 25th, 2006 · 5 Comments
In this blog entry, I will demonstrate a very simple Hello World application using C# and Avalon, and attempt to explain how it works, and how the XAML and the C# code are all hooked up together. All the information and code is based on the February 2006 CTP, and may be subject to change [...]
Tags: WPF (Avalon)
Avalon with C++/CLI – what are your options?
March 31st, 2006 · 8 Comments
As of today (Feb CTP), Visual C++ projects cannot have XAML in them as C# and VB projects can. Of course, this does not mean that you cannot target Avalon using C++, and if you have read my previous blog entries, you’d have seen a couple of ways how that can be done. To put [...]
Tags: C++/CLI · WPF (Avalon)
Avalon – The end of HWND voyeurism!
March 30th, 2006 · 3 Comments
One fundamental aspect about Avalon controls is that they are not native HWND based controls, such as the ones you have been used to with Win32 API programming or with Windows Forms (which merely wraps the API). So if you have an Avalon window with a bunch of controls on it (say a ListBox and [...]
Tags: WPF (Avalon)
Dynamically load a Xaml file from a C++ app
March 25th, 2006 · 6 Comments
While it’s an absolute tragedy that C++ does not directly support compiled Xaml, you can use Xaml dynamically from a C++ Avalon app using XamlReader::Load. Let me show you how to do that, using a simple example. You can create your Xaml file, either using a text editor or using a temporary dummy C# or [...]
Tags: VC++ 2005 · WPF (Avalon)
Writing a simple Avalon app with C++/CLI
March 16th, 2006 · 5 Comments
You cannot use XAML with C++/CLI, so you’ll have to hand-code your UI, as of now anyway. Anyway, here’s what you need to do to write a simple app. Step 1 Generate a new C++/CLI project, set the subsystem to Windows, set the entry point to main, and add the following references : System (if [...]
Tags: WPF (Avalon)