Silverlight 4: Free Split Button

耗尽温柔 提交于 2019-12-07 19:17:58

问题


I'm looking for free splitbutton control for silverlight.

I've seen this blog however I cannot download it. Its blocked in my firewall.

Do you know any free splitbutton for silverlight?

Thank you


回答1:


It is available for free in the Silverlight Toolkit.

  1. Download the latest Silverlight Toolkit from CodePlex.

    http://silverlight.codeplex.com/
    
  2. Download the SplitButton Samples and Project. You may use the SplitButton project to compile your own version of the SplitButton.dll or use the Sample programs to study. (optional)

    http://dlaa.me/Samples/SplitButton/SplitButton.zip
    
  3. Add references (right click References) to the Silverlight toolkit and the SplitButton.dll in your Silverlight project.

    SplitButton.dll
    System.Windows.Controls.Input.Toolkit.dll
    
  4. Add both namespaces to your XAML, for the Silverlight toolkit and the new SplitButton.

    xmlns:splitButton="clr-namespace:Delay;assembly=SLTKSplitButton"
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
    
  5. Add the Split Button code. This makes one button that drops to three options.

    <splitButton:SplitButton x:Name='Button1' Content="Open" Click="Button1_Clicked"> 
      <splitButton:SplitButton.ButtonMenuItemsSource>
          <toolkit:MenuItem Header="Open" Click="Button1_Clicked" />
          <toolkit:MenuItem Header="Open read-only" Click="Button1_ClickedRO" />
          <toolkit:MenuItem Header="Open as copy" Click="Button1_ClickedAC" />
      </splitButton:SplitButton.ButtonMenuItemsSource>
    </splitButton:SplitButton>
    
  6. Add Csharp code for click handlers for main button click or any of the three sub-option clicks.

    private void Button1_Clicked(object sender, RoutedEventArgs e)
    {
      MessageBox.Show("Opening document normally...");
    }
    
    private void Button1_ClickedRO(object sender, RoutedEventArgs e)
    {
      MessageBox.Show("Opening document read-only...");
    }
    
    private void Button1_ClickedAC(object sender, RoutedEventArgs e)
    {
      MessageBox.Show("Opening document as a copy...");
    }
    
  7. Give thanks to David Anson, a Microsoft developer who works with the Silverlight, Windows Phone, and WPF platforms. Twitter: @DavidAns



来源:https://stackoverflow.com/questions/4560106/silverlight-4-free-split-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!