Monday, September 3, 2007
Correct use DataTemplateSelector.
In the many inherited from FrameworkElement in WPF contain a useful dependency property *TemplateSelector type of DataTemplateSelector. It can set our inherit from DataTemplateSelector class and override the method SelectTemplate(). This allow dynamic generate template for a content. Content-data we can get a elementary binding. And now feature: we can use all binding (even that what refet to ElementName), except TemplateBinding, therefore RelativSourceMode doesn't equal TemplatedParent.
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).
Enjoy!
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).
Enjoy!
"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):
<ListBox>
<ListBox.Resources>
<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" />
</ListBox.Resources>
<ListBoxItem>blah-blah</ListBoxItem>
<ListBoxItem>blah-blah</ListBoxItem>
<ListBoxItem>blah-blah</ListBoxItem>
</ListBox>
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.
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..
Tuesday, July 24, 2007
Subscribe to:
Posts (Atom)