Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

databinding trigger

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-31-2006   #1 (permalink)
Arnaud Fontaine
Guest


 

databinding trigger

I try to create a ListBoxStyle associated with several templates. I would
like to bind dynamically each items to its corresponding template, according
to the value of a field on items.

Have you already use a Trigger with a Binding condition (source code below),
or is there an other way to do a such construction.

<Style x:Key="SmallRosterListItem" TargetType="{x:Type ListBoxItem}">
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template" Value="{StaticResource
item_SmallRosterDetails}" />

<Setter Property="Padding" Value="0,0,0,0" />
<Style.Triggers>
<Trigger Property="Binding XPath=gender" Value="Male">
<Setter Property="Template" Value="{StaticResource
item_BigRosterMale}" />
</Trigger>
</Style>

My System SpecsSystem Spec
Old 01-31-2006   #2 (permalink)
MueMeister
Guest


 

Re: databinding trigger

Hi Arnaud,

I you want to change the look of your items in the listbox depending on
a special value on this item you could try to implement your own custom
ItmeTemplateSelector class. This class decides with your application
logic which DataTemplate to choose.

This is what you want, I think: http://www.beacosta.com/

Chris

Arnaud Fontaine wrote:
> I try to create a ListBoxStyle associated with several templates. I would
> like to bind dynamically each items to its corresponding template, according
> to the value of a field on items.
>
> Have you already use a Trigger with a Binding condition (source code below),
> or is there an other way to do a such construction.
>
> <Style x:Key="SmallRosterListItem" TargetType="{x:Type ListBoxItem}">
> <Setter Property="Cursor" Value="Hand" />
> <Setter Property="Background" Value="Transparent" />
> <Setter Property="Template" Value="{StaticResource
> item_SmallRosterDetails}" />
>
> <Setter Property="Padding" Value="0,0,0,0" />
> <Style.Triggers>
> <Trigger Property="Binding XPath=gender" Value="Male">
> <Setter Property="Template" Value="{StaticResource
> item_BigRosterMale}" />
> </Trigger>
> </Style>

My System SpecsSystem Spec
Old 01-31-2006   #3 (permalink)
Drew Marsh
Guest


 

Re: databinding trigger

Arnaud Fontaine wrote:

> I try to create a ListBoxStyle associated with several templates. I
> would like to bind dynamically each items to its corresponding
> template, according to the value of a field on items.
>
> Have you already use a Trigger with a Binding condition (source code
> below), or is there an other way to do a such construction.


You would use a property trigger[1] on the property which value you want
to react to change the style of the template accordingly. If changing your
style depends on multiple properties, then use a multi-trigger[2].

HTH,
Drew

[1] http://windowssdk.msdn.microsoft.com...ws_Trigger.asp
[2] http://windowssdk.msdn.microsoft.com...ltiTrigger.asp

___________________________________
Drew Marsh
Chief Software Architect
Mimeo.com, Inc. - http://www.mimeo.com
Microsoft C# / WPF MVP
Weblog - http://blog.hackedbrain.com/


My System SpecsSystem Spec
Old 01-31-2006   #4 (permalink)
Arnaud Fontaine
Guest


 

Re: databinding trigger

Hi Chris

This is exacltly what I was looking for. Thanks!!

Arnaud

"MueMeister" wrote:

> Hi Arnaud,
>
> I you want to change the look of your items in the listbox depending on
> a special value on this item you could try to implement your own custom
> ItmeTemplateSelector class. This class decides with your application
> logic which DataTemplate to choose.
>
> This is what you want, I think: http://www.beacosta.com/
>
> Chris
>
> Arnaud Fontaine wrote:
> > I try to create a ListBoxStyle associated with several templates. I would
> > like to bind dynamically each items to its corresponding template, according
> > to the value of a field on items.
> >
> > Have you already use a Trigger with a Binding condition (source code below),
> > or is there an other way to do a such construction.
> >
> > <Style x:Key="SmallRosterListItem" TargetType="{x:Type ListBoxItem}">
> > <Setter Property="Cursor" Value="Hand" />
> > <Setter Property="Background" Value="Transparent" />
> > <Setter Property="Template" Value="{StaticResource
> > item_SmallRosterDetails}" />
> >
> > <Setter Property="Padding" Value="0,0,0,0" />
> > <Style.Triggers>
> > <Trigger Property="Binding XPath=gender" Value="Male">
> > <Setter Property="Template" Value="{StaticResource
> > item_BigRosterMale}" />
> > </Trigger>
> > </Style>

>

My System SpecsSystem Spec
Old 01-31-2006   #5 (permalink)
Drew Marsh
Guest


 

Re: databinding trigger

I wrote:

> You would use a property trigger[1] on the property which value you
> want to react to change the style of the template accordingly. If
> changing your style depends on multiple properties, then use a
> multi-trigger[2].


Sorry, misunderstood the question. MueMeister was right, ItemTemplateSelector
is your friend.

Cheers,
Drew


My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Trigger Data Binding to Method Runar Jordahl Avalon 5 10-17-2007 07:24 PM
Trigger Storyboard from c# code timmy@trashymail.com Avalon 0 08-14-2007 12:04 PM
How do you trigger MCE in Vista Ultimate? MrMikeH Vista music pictures video 1 01-19-2007 02:39 PM
trigger for IsFocused - not working? CosminB [BRT] Avalon 0 04-22-2006 02:00 AM
Can trigger work outside a style ? Philippe Lavoie Avalon 1 03-15-2006 10:21 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51