Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts 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

Templated ComboBox fires SelectionChanged twice

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-04-2007   #1 (permalink)
Keith Patrick
Guest


 

Templated ComboBox fires SelectionChanged twice

I have a combobox that I styled to have another combo box inside it (to add
some visual functionality). However, because I have two combos (the logical
and the visual) that are two-way bound to one another, when I make a
selection, the SelectionChanged event fires twice. I'm not sure how to mask
the event when it's triggered via a binding outside taking my custom
template out altogether, which isn't an option:
<Style x:Key="PickList"
TargetType="{x:Type ComboBox}">
<Setter Property="MinWidth"
Value="150"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBox}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="19"/>
</Grid.ColumnDefinitions>

<ComboBox Grid.ColumnSpan="2"
ItemsSource="{TemplateBinding
ItemsSource}"
ItemTemplate="{TemplateBinding
ItemTemplate}"
SelectedItem="{Binding
RelativeSource={x:Static RelativeSource.TemplatedParent}, Path=SelectedItem,
Mode=TwoWay}"
MinHeight="{TemplateBinding
MinHeight}"
MinWidth="{TemplateBinding
MinWidth}"/>
<Border Margin="2,2,2,1"
I****TestVisible="False">
<StackPanel Name="SelectLabel"
Visibility="Hidden"
Orientation="Horizontal"
HorizontalAlignment="Center"
Margin="{TemplateBinding
Control.Padding}">
<TextBlock Style="{StaticResource
PickListNullItem}"
Text="Select a "/>
<TextBlock Style="{StaticResource
PickListNullItem}"
Text="{TemplateBinding
Name}"/>
</StackPanel>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="SelectedItem"
Value="{x:Null}">
<Setter Property="Visibility"
Value="Visible"
TargetName="SelectLabel"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>



My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows Defender: Event 3004 never fires ruisu Vista security 0 08-22-2008 06:53 PM
Is there an event that real fires for sure only once UserControl L Schwartzenberg Avalon 3 05-23-2008 06:21 AM
Mnemonics in WPF ComboBox Oleg Ogurok Avalon 0 10-16-2007 02:04 PM
Custom Combobox in WPF askaile Avalon 2 09-24-2007 02:47 AM
ComboBox Problem Bahadýr ARSLAN Avalon 0 08-20-2007 01:47 AM


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