Spread WPF Documentation
ToolbarButton Constructor
Example 


GrapeCity.Windows.SpreadSheet.UI Namespace > ToolbarButton Class : ToolbarButton Constructor
The title.
The image source.
Initializes a new instance of the ToolbarButton class.
Syntax
'Declaration
 
Public Function New( _
   ByVal title As System.String, _
   ByVal imageSource As System.Windows.Media.ImageSource _
)
'Usage
 
Dim title As System.String
Dim imageSource As System.Windows.Media.ImageSource
 
Dim instance As New ToolbarButton(title, imageSource)
public ToolbarButton( 
   System.string title,
   System.Windows.Media.ImageSource imageSource
)

Parameters

title
The title.
imageSource
The image source.
Example
This example adds images to the touch toolbar.
private GrapeCity.Windows.SpreadSheet.UI.TouchToolbar _toolbar;
     
       public MainWindow()
       {
           InitializeComponent();
           this.InitializeTouchStrip();
       }    

       void autoFill_Click(object sender, EventArgs e)
       {
           var activeView = this.GcSpreadSheet1.View;
           if (activeView != null)
           {
               activeView.ShowAutoFillIndicator();
           }
       }

       private void InitializeTouchStrip()
       {
           _toolbar = GrapeCity.Windows.SpreadSheet.UI.TouchToolbarFactory.CreateCutCopyPasteToolBar(this.GcSpreadSheet1.View);
           foreach (var item in _toolbar.ToolbarItems)
           {
               var toolbarButton = item as GrapeCity.Windows.SpreadSheet.UI.ToolbarButton;
               if (toolbarButton != null && toolbarButton.Title == "Cut")
               {
                   toolbarButton.Visibility = System.Windows.Visibility.Collapsed;
                   break;
               }
           }
           var separator1 = new GrapeCity.Windows.SpreadSheet.UI.ToolbarSeparator();
           _toolbar.ToolbarItems.Add(separator1);
           var autoFillButton = GrapeCity.Windows.SpreadSheet.UI.TouchToolbarFactory.CreateDragFillButton();
           _toolbar.ToolbarItems.Add(autoFillButton);
           var separator2 = new GrapeCity.Windows.SpreadSheet.UI.ToolbarSeparator();
           _toolbar.ToolbarItems.Add(separator2);

           var grid = new Grid();
           grid.RowDefinitions.Add(new RowDefinition());
           grid.RowDefinitions.Add(new RowDefinition());
           var row1 = new StackPanel { Orientation = Orientation.Horizontal };
           var row2 = new StackPanel { Orientation = Orientation.Horizontal };
           Grid.SetRow(row1, 0);
           Grid.SetRow(row2, 1);
           grid.Children.Add(row1);
           grid.Children.Add(row2);

           Uri uri = new Uri("C:\\info.png", UriKind.Absolute);
           BitmapImage img = new BitmapImage(uri);
           row1.Children.Add(new GrapeCity.Windows.SpreadSheet.UI.ToolbarButton(null, img));
           row1.Children.Add(new GrapeCity.Windows.SpreadSheet.UI.ToolbarButton(null, img));
           row2.Children.Add(new GrapeCity.Windows.SpreadSheet.UI.ToolbarButton(null, img));
           row2.Children.Add(new GrapeCity.Windows.SpreadSheet.UI.ToolbarButton(null, img));
           _toolbar.ToolbarItems.Add(grid);
           var separator3 = new GrapeCity.Windows.SpreadSheet.UI.ToolbarSeparator();
           _toolbar.ToolbarItems.Add(separator3);
           var toolbarDropdown = new GrapeCity.Windows.SpreadSheet.UI.ToolbarDropDown();
           var menu = new ContextMenu();
           menu.Items.Add("Item1");
           toolbarDropdown.Menu = menu;
           _toolbar.ToolbarItems.Add(toolbarDropdown);
       }

       private void GcSpreadSheet1_TouchToolbarOpening(object sender, GrapeCity.Windows.SpreadSheet.UI.TouchToolbarOpeningEventArgs e)
       {
           e.Handled = true;
           _toolbar.Show(e.X - 100, e.Y - 100);          
       }
Private _toolbar As GrapeCity.Windows.SpreadSheet.UI.TouchToolbar

    Public Sub New()
        InitializeComponent()
        Me.InitializeTouchStrip()
    End Sub

    Private Sub GcSpreadSheet1_TouchToolbarOpening(sender As Object, e As GrapeCity.Windows.SpreadSheet.UI.TouchToolbarOpeningEventArgs) Handles GcSpreadSheet1.TouchToolbarOpening
        e.Handled = True
        _toolbar.Show(e.X - 100, e.Y - 100)
    End Sub

    Private Sub autoFill_Click(sender As Object, e As EventArgs)
        Dim activeView = Me.GcSpreadSheet1.View
        If activeView IsNot Nothing Then
            activeView.ShowAutoFillIndicator()
        End If
    End Sub

    Private Sub InitializeTouchStrip()
        _toolbar = GrapeCity.Windows.SpreadSheet.UI.TouchToolbarFactory.CreateCutCopyPasteToolBar(Me.GcSpreadSheet1.View)
        For Each item In _toolbar.ToolbarItems
            Dim toolbarButton = TryCast(item, GrapeCity.Windows.SpreadSheet.UI.ToolbarButton)
            If toolbarButton IsNot Nothing AndAlso toolbarButton.Title = "Cut" Then
                toolbarButton.Visibility = System.Windows.Visibility.Collapsed
                Exit For
            End If
        Next
        Dim separator1 = New GrapeCity.Windows.SpreadSheet.UI.ToolbarSeparator()
        _toolbar.ToolbarItems.Add(separator1)
        Dim autoFillButton = GrapeCity.Windows.SpreadSheet.UI.TouchToolbarFactory.CreateDragFillButton()
        _toolbar.ToolbarItems.Add(autoFillButton)
        Dim separator2 = New GrapeCity.Windows.SpreadSheet.UI.ToolbarSeparator()
        _toolbar.ToolbarItems.Add(separator2)

        Dim grid__1 = New Grid()
        grid__1.RowDefinitions.Add(New RowDefinition())
        grid__1.RowDefinitions.Add(New RowDefinition())
        Dim row1 = New StackPanel() With { _
            .Orientation = Orientation.Horizontal _
        }
        Dim row2 = New StackPanel() With { _
            .Orientation = Orientation.Horizontal _
        }
        Grid.SetRow(row1, 0)
        Grid.SetRow(row2, 1)
        grid__1.Children.Add(row1)
        grid__1.Children.Add(row2)

        Dim uri As New Uri("C:\info.png", UriKind.Absolute)
        Dim img As New BitmapImage(uri)
        row1.Children.Add(New GrapeCity.Windows.SpreadSheet.UI.ToolbarButton(Nothing, img))
        row1.Children.Add(New GrapeCity.Windows.SpreadSheet.UI.ToolbarButton(Nothing, img))
        row2.Children.Add(New GrapeCity.Windows.SpreadSheet.UI.ToolbarButton(Nothing, img))
        row2.Children.Add(New GrapeCity.Windows.SpreadSheet.UI.ToolbarButton(Nothing, img))
        _toolbar.ToolbarItems.Add(grid__1)
        Dim separator3 = New GrapeCity.Windows.SpreadSheet.UI.ToolbarSeparator()
        _toolbar.ToolbarItems.Add(separator3)
        Dim toolbarDropdown = New GrapeCity.Windows.SpreadSheet.UI.ToolbarDropDown()
        Dim menu = New GrapeCity.Windows.SpreadSheet.UI.ContextMenu()
        menu.Items.Add("Item1")
        toolbarDropdown.Menu = menu
        _toolbar.ToolbarItems.Add(toolbarDropdown)
    End Sub
See Also

Reference

ToolbarButton Class
ToolbarButton Members