Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Templated ComboBox fires SelectionChanged twice

 
 
Old 01-04-2007   #1 (permalink)
Keith Patrick


 
 

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
 

Thread Tools


Similar Threads
Thread Forum
dataGridView CellContentClick fires after CellDoubleClick .NET General
Serious Fires Chillout Room
leave event fires disabling textbox below -cursor stays in 1st tex .NET General
Windows Defender: Event 3004 never fires Vista security


Vista Forums 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 Ltd

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