Quantcast
Channel: wpftoolkit Discussions Rss Feed
Viewing all articles
Browse latest Browse all 2157

New Post: SplitButton with dropdown menu

$
0
0
Hi,

1) Try adding a click event to your menuItems and tell the splitButton to close :
<xctk:SplitButton x:Name="_splitButton"
                           Content="Click Me"
         <xctk:SplitButton.DropDownContent>
            <Menu>
               <MenuItem Header="First" 
                         Click="MenuItem_Click"/>
               <MenuItem Header="Second"
                         Click="MenuItem_Click" />
               <MenuItem Header="Third option for this menu"
                         Click="MenuItem_Click" />
           </Menu>
         </xctk:SplitButton.DropDownContent>
</xctk:SplitButton>

private void MenuItem_Click( object sender, RoutedEventArgs e )
    {
      _splitButton.IsOpen = false;
    }
2) I don't know with what object you want to bind the menuItems, but, here's an example if you have a CheckBox:
<StackPanel 
         <CheckBox x:Name="_checkBox" IsChecked="True"/>
         <xctk:SplitButton x:Name="_splitButton"
                           Content="Click Me"
            <xctk:SplitButton.DropDownContent>
               <Menu>
                  <MenuItem Header="First"
                            Click="MenuItem_Click" />
                  <MenuItem Header="Second"
                            Click="MenuItem_Click"
                            IsChecked="{Binding Source={x:Reference _checkBox}, Path=IsChecked}" />
                 </Menu>
            </xctk:SplitButton.DropDownContent>
         </xctk:SplitButton>
      </StackPanel>
Or you can set the DataContext, of the splitButton with the Checkbox, as mentioned on this site : http://stackoverflow.com/questions/20522228/ischecked-binding-not-working-in-menuitem-in-a-contextmenu

Viewing all articles
Browse latest Browse all 2157

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>