![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| 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 Specs![]() |
| | #2 (permalink) |
| 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 Specs![]() |
| | #3 (permalink) |
| 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 Specs![]() |
| | #4 (permalink) |
| 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 Specs![]() |
| | #5 (permalink) |
| 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 Specs![]() |
![]() |
| 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 |