WPF Designer

Thursday, January 15, 2009

There are times in which you would have code that does some runtime work that will cause the designer to fail loading the WPF content and display the error. At such times, you might want to tweak your code to support this need. Let's look at the following example for a converter:public class TemplatePickEnabledConverter : IMultiValueConverter{    public object Convert(object values, Type targetType, object parameter, System.Globalization.CultureInfo culture)    {        int id = (int)values;        //Do Something..    }} Using this converter in XAML will cause the designer to fail loading the content. There are generally 3 ways to go about it. Context-based Use Logical Validation DesignMode Awareness 1) Context-based Use The idea...
tags: ,
no comments

Toolkit Updates

Make sure you check the latest source and bits of: WPF Toolkit DataGrid v1 DatePicker/Calendar v1 Visual State Manager Preview Ribbon Preview Silverlight Toolkit AutoCompleteBox NumericUpDown Viewbox Expander ImplicitStyleManager Charting TreeView DockPanel WrapPanel Label HeaderedContentControl HeaderedItemsControl Themes - Expression Dark / Light | Rainier Purple / Orange | Shiny Blue / Red
no comments

Custom Window Chrome in WPF

Via this post. "This document covers the design and some implementation details of getting WPF windows wrapped in custom chrome. Currently WPF supports standard windows, with an icon, title-text, and caption buttons, as well as borderless windows, which when combined with transparency allow arbitrary top-level shapes but the application loses system support for behaviors associated with having a standard caption area, such as maximize. There is a desire to create applications that fill a middle-ground here: the appearance and behavior of a standard window with a more complete branding experience" Get the code here.
tags: ,
no comments

WPF Popups and ToolTip behavior – A Journey

I am currently working on a WPF project which I needed a ToolTip with a certain behavior:It should act like a ToolTip Support content templateAppear upon hovering with a small intervalAppear once - hovering another element with a tooltip should hide the last shown tooltip.Support Rich Content The latter is marked as bold since that was the essential requirement that made me not use the ordinary WPF ToolTip.I needed the ToolTip to hold rich content - such as clickable buttons.This also implicates that I wanted the ToolTip to remain shown until either one of the followingThe window was moved/size changedThe...
tags: ,
one comment

WPF Popups and ToolTip Behavior – Implementation

In continuation to my first post -WPF Popups and ToolTip behavior - A JourneyI decided to approach the implementation of such a popup like the ToolTip and ContextMenu are doing it themselves.I did not inherit from Popup but rather created my own control and I used the Popup.CreateRootPopup which sets the Popup.Child property to my control and it picks up on all the ToolTipService properties defined on my control.I started from reading the following post:Popup your controlThere were some problems with this pattern though, I had to overcome these with quite many event hooking which I'm not very happy...
tags: ,
no comments

WPF 3.5 SP1 Feature – StringFormat

Via this post. I won't elaborate so much about it, do read Lester's post in the link above. The new feature introduces useful and simple usage to control string formatting in binding statements. No need to use converter everywhere :) A good thing!<TextBox Text="{Binding Path=Double, StringFormat=F3}"/>
tags: ,
no comments

WPF Binding Expression Alternatives

Via this post from WiredPrairie blog. The post holds links that explain approaches for extending the binding extensions. Extending "Binding" or "BindingBase" is pretty tacky, this is due to the fact that BindingBase.ProvideValue is sealed.The posts illustrate an elegant approach for wrapping it up and creating your own MarkUp extension to provide you with the functionality you desire.
tags: ,
one comment

WPF – Layout To Layout Animations

A pretty common animation when dealing with WPF is the transition of an element from layout to layout. Take the following scenario:Let's say I got a window with a form-like view.The form has a rich textbox where the user can enter lots of content.In this case, I would like to give the user the possibility to expand that textbox if he needs to edit it in a more convenient way.So I go and add an expand button, when clicked I add the textbox as a child to a grid that is placed on the entire window's size.Of course, collapsing it...
tags: ,
no comments

WPF – Selected Item Style

I got around building a decent amount of controls that derived from ListBox. The default template of a ListBoxItem contains default style for the selection triggered by various triggers. If you wish to control the colors, you can adjust it by the following: <ListBox.Resources>  <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />  <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" /></ListBox.Resources>  If you wish to alter the selection/any other actual behavior: you can replave the default template of the ListBoxItem and edit anything you like, the following example is a duplicate of the default template with comments on what you should remove if you like to disable selection highlighting. <ControlTemplate TargetType="{x:Type...
tags: ,
no comments