views:

77

answers:

1

Hi ,

I am using a code snippet from codeproject of dropdown button.

<    m:SplitButton Content="TWB" Name="btnSearch"
                          Grid.Row="0" Grid.Column="0"
                          Style="{StaticResource aeroNormalColorSplitButtonStyle}"
                          Click="btnSearch_Click" 
                          Width="60" Height="30"
                          VerticalAlignment="Center" 
                          HorizontalAlignment="Left"   
                          Mode="{Binding ElementName=modeSelector, Path=SelectedItem}"
                          Placement="{Binding ElementName=placementSelector, Path=SelectedItem}" MouseLeftButtonDown="btnSearch_MouseLeftButtonDown"
                                MenuItem Header="TWB"/&gt;
                                MenuItem Header="PWB"&gt;
                                /MenuItem&gt;
                          </m:SplitButton>

so, beside this splitdown button, I have a textbox(which is basically a search box). So, as the above code snippet shows the 2 menu items as "TWB" and "PWB", I have to fill the textbox when TWB is selected from the dropdown button and also the same text should be displayed on the button too (TWB).

if i click PWB from the dropdownbutton, I should get the "PWB" name on the button and the same PWB name should be displayed in the textbox too.

Please help me.

Thank You, Ramm

A: 

Hi,

I tried by adding ListBox to the SplitButton, Now I am able to see the text in the textbox.

Modified the above Xaml code to

<m:SplitButton Content="TWB" Name="btnSearch"
     Grid.Row="0" Grid.Column="0"
     Style="{StaticResource aeroNormalColorSplitButtonStyle}"
     Click="btnSearch_Click" 
     Width="60" Height="30"
     VerticalAlignment="Center" 
     HorizontalAlignment="Left"  
     Mode="{Binding ElementName=modeSelector, Path=SelectedItem}"
     Placement="{Binding ElementName=placementSelector, Path=SelectedItem}">
                    <ListBox x:Name="TransitionKind" SelectionChanged="TransitionKind_SelectionChanged">
                        <ListBoxItem Content="TWB"/>
                        <ListBoxItem Content="PWB"/>
                    </ListBox>
                </m:SplitButton>

in the code behind,

btnSearch.Click += new RoutedEventHandler(btnSearch_Click); TransitionKind.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(TransitionKind_SelectionChanged);

private void TransitionKind_SelectionChanged(object sender, SelectionChangedEventArgs e) { btnSearch.Content = ((ListBoxItem)TransitionKind.SelectedItem).Content; txtBxSearch.Text = "Search " + (string) btnSearch.Content; }

Now, I am able to see the text in the textbox changing to the click of dropdown button.

Thank you, Ramm

Aditya