Wednesday, July 25, 2007

My Vista sidebar gadget :)

I create Vista sidebar gadget for UA gadget competitions. It was adds to follow page iTV Watcher.
I had wanted to use SilverLight 1.0 (version 2.0 wasn't accessible in this time) for this purpose but I can't overcome a problem with event if to use Silverlight in sidebar of Vista. So I must was to use a simple JavaScript (It was missed some WPF-like animations feature, but it work correct).

"Cruel" colors substitution.

Sometime we need custom one or more brush of control in WPF. If template is not available and in base template used system brush, we can use this workaround (example for ListBox):
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Maroon" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Maroon" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="White" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="White" />

Custom style for a class which is inherited from the class of Selector

We need set own custom style or template for item of control which was inheritance from abstract class 'Selector' (for example: ComboBox, ListBox, TabControl) in WPF.
We can use two way:
1) We can add in control's resource some style and template. But it isn't good way, because these styles and templates have access only in boundary of control.
2) We can use inheritance from Selector ItemContainerStyle dependency property and set in it new style value.

Correct works of MultiDataTrigger.

Sometimes we will be use a few MultiDataTrigger in WPF and them contain one identical binding. As practice shows better way is write identical binding to last in the list of condition, in other case MultiDataTrigger works not always. For the other types of MultiTriggers the it was unchecked, although scarcely it isn't identical..