WPF

Code Examples Upgrade Guide User Guide Demos Support Forums Download
  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class Stencil

    Show / Hide Table of Contents

    Class Stencil

    Represents the library of shapes.

    Inheritance
    System.Object
    Stencil
    Namespace: Syncfusion.UI.Xaml.Diagram.Stencil
    Assembly: Syncfusion.SfDiagram.WPF.dll
    Syntax
    public class Stencil : Control

    Constructors

    Stencil()

    Initializes a new instance of the Stencil class.

    Declaration
    public Stencil()

    Fields

    CategoriesProperty

    Using a DependencyProperty as the backing store for Categories property. This enables animation, styling, binding, etc...

    Declaration
    public static DependencyProperty CategoriesProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    ConstraintsProperty

    Using a DependencyProperty as the backing store for Constraints property. This enables animation, styling, binding, etc...

    Declaration
    public static DependencyProperty ConstraintsProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    DiagramThemeProperty

    Identifies the DiagramTheme dependency property.

    Declaration
    public static DependencyProperty DiagramThemeProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    DisplayModeProperty

    Using a DependencyProperty as the backing store for DisplayMode property. This enables animation, styling, binding, etc...

    Declaration
    public static readonly DependencyProperty DisplayModeProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    ExpandModeProperty

    Using a DependencyProperty as the backing store for ExpandMode property. This enables animation, styling, binding, etc...

    Declaration
    public static DependencyProperty ExpandModeProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    HeaderVisibilityProperty

    Using a DependencyProperty as the backing store for HeaderVisibility property. This enables animation, styling, binding, etc...

    Declaration
    public static DependencyProperty HeaderVisibilityProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    ItemAddingCommandProperty

    Identifies the ItemAddingCommand dependency property.

    Declaration
    public static DependencyProperty ItemAddingCommandProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    ItemDeletingCommandProperty

    Identifies the ItemDeletingCommand dependency property.

    Declaration
    public static DependencyProperty ItemDeletingCommandProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    MenuItemClickedCommandProperty

    Identifies the MenuItemClickedCommand dependency property.

    Declaration
    public static DependencyProperty MenuItemClickedCommandProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    MenuOpeningCommandProperty

    Identifies the MenuOpeningCommand dependency property.

    Declaration
    public static DependencyProperty MenuOpeningCommandProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    MenuProperty

    Identifies the Menu dependency property.

    Declaration
    public static DependencyProperty MenuProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    SelectedFilterProperty

    Using a DependencyProperty as the backing store for SelectedFilter property. This enables animation, styling, binding, etc...

    Declaration
    public static DependencyProperty SelectedFilterProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    SelectedItemsProperty

    Identifies the SelectedItems dependency property.

    Declaration
    public static DependencyProperty SelectedItemsProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    SelectedSymbolProperty

    Using a DependencyProperty as the backing store for SelectedSymbol. This enables animation, styling, binding, etc...

    Declaration
    public static DependencyProperty SelectedSymbolProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    SelectionChangedCommandProperty

    Identifies the SelectionChangedCommand dependency property.

    Declaration
    public static DependencyProperty SelectionChangedCommandProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    ShowDisplayModeToggleButtonProperty

    Using a DependencyProperty as the backing store for ShowDisplayModeToggleButton property. This enables animation, styling, binding, etc...

    Declaration
    public static readonly DependencyProperty ShowDisplayModeToggleButtonProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    ShowSearchTextBoxProperty

    Using a DependencyProperty as the backing store for ShowSearchTextBox property. This enables animation, styling, binding, etc...

    Declaration
    public static readonly DependencyProperty ShowSearchTextBoxProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    SymbolFilterDisplayModeProperty

    Using a DependencyProperty as the backing store for SymbolFilterDisplayMode property. This enables animation, styling, binding, etc...

    Declaration
    public static readonly DependencyProperty SymbolFilterDisplayModeProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    SymbolFiltersProperty

    Using a DependencyProperty as the backing store for SymbolFilters property. This enables animation, styling, binding, etc...

    Declaration
    public static DependencyProperty SymbolFiltersProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    SymbolGroupProperty

    Using a DependencyProperty as the backing store for SymbolGroup property. This enables animation, styling, binding, etc...

    Declaration
    public static DependencyProperty SymbolGroupProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    SymbolGroupsProperty

    Using a DependencyProperty as the backing store for SymbolGroup property. This enables animation, styling, binding, etc...

    Declaration
    public static DependencyProperty SymbolGroupsProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    SymbolPreviewProperty

    Using a DependencyProperty as the backing store for SymbolPreview. This enables animation, styling, binding, etc...

    Declaration
    public static DependencyProperty SymbolPreviewProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    SymbolsDisplayModeProperty

    Identifies the SymbolsDisplayMode dependency property.

    Declaration
    public static DependencyProperty SymbolsDisplayModeProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    SymbolSourceProperty

    Identifies the Syncfusion.UI.Xaml.Diagram.Stencil.SymbolSource dependency property.

    Declaration
    public static DependencyProperty SymbolSourceProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    TitleProperty

    Using a DependencyProperty as the backing store for Title property. This enables animation, styling, binding, etc...

    Declaration
    public static readonly DependencyProperty TitleProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    TitleTemplateProperty

    Using a DependencyProperty as the backing store for TitleTemplate property. This enables animation, styling, binding, etc...

    Declaration
    public static readonly DependencyProperty TitleTemplateProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    Properties

    Categories

    Gets or sets the stencil groups collection.

    Declaration
    public StencilCategoryCollection Categories { get; set; }
    Property Value
    Type Description
    StencilCategoryCollection
    Examples

    Below example shows how to group the symbols in the stencil. #MainWindow.xaml

    <!--Initialize the stencil-->
    <Stencil:Stencil x:Name="stencil">
        <!--Initialize the stencil categories-->
        <Stencil:Stencil.Categories>
            <Stencil:StencilCategoryCollection>
                <!--Specify the basic shapes category with title and resource key-->
                <Stencil:StencilCategory Title = "Basic Shapes" Keys="{StaticResource BasicShapes}"/>
                <Stencil:StencilCategory Title = "Flow Shapes" Keys="{StaticResource FlowShapes}"/>
                <Stencil:StencilCategory Title = "Arrow Shapes" Keys="{StaticResource ArrowShapes}"/>
            </Stencil:StencilCategoryCollection>
        </Stencil:Stencil.Categories>
       <!--Initialize the SymbolGroup-->
       <stencil:Stencil.SymbolGroups>
           <stencil:SymbolGroups>
               <!--Map Symbols Using MappingName-->
               <stencil:SymbolGroupProvider MappingName = "Key" >
               </ stencil:SymbolGroupProvider>
           </stencil:SymbolGroups>
       </stencil:Stencil.SymbolGroups>
    </stencil:Stencil>

    #MainWindow.xaml.cs

       //Collection of Symbols
       public class SymbolCollection : ObservableCollection<object>
       {
    
       }

    Constraints

    Gets or sets the default behaviours of stencil.

    Declaration
    public StencilConstraints Constraints { get; set; }
    Property Value
    Type Description
    StencilConstraints

    DiagramTheme

    Gets or sets the theme to a collection of property settings that allow you to define the look of stencil elements.

    Declaration
    public DiagramTheme DiagramTheme { get; set; }
    Property Value
    Type Description
    DiagramTheme

    DisplayMode

    Gets or sets a value that specifies how the stencil and content areas of a stencil are being shown. A value of the enumeration that specifies how the stencil and content areas of a stencil are being shown.

    Declaration
    public DisplayMode DisplayMode { get; set; }
    Property Value
    Type Description
    DisplayMode
    Examples
     <syncfusion:Stencil x:Name="stencil" Width="250"  DisplayMode="Compact">
         <!--Initialize the SymbolSource-->
          <syncfusion:Stencil.SymbolSource>               
           <!--Define the SymbolCollection-->
                   <syncfusion:SymbolCollection>
                     <syncfusion:NodeViewModel Key = "Basic Shapes" Name="Triangle" OffsetX="100" OffsetY="100" UnitHeight="100" UnitWidth="100"  Shape="{StaticResource Triangle}" ShapeStyle="{StaticResource nodestyle}" >
                    </syncfusion:NodeViewModel>
                    </syncfusion:SymbolCollection>
                </syncfusion:Stencil.SymbolSource>
            <syncfusion:Stencil.SymbolGroups>
                <syncfusion:SymbolGroups>
                    <!--Separate groups based on the key-->
               <syncfusion:SymbolGroupProvider MappingName = "Key" />
              </ syncfusion:SymbolGroups>
            </syncfusion:Stencil.SymbolGroups>
          </syncfusion:Stencil>

    ExpandMode

    Gets or sets a value that indicates the number of symbol group expanded in stencil.

    Declaration
    public ExpandMode ExpandMode { get; set; }
    Property Value
    Type Description
    ExpandMode
    Remarks

    This is applicable only for the DisplayMode as ComboBox

    HeaderVisibility

    Gets or sets the header visibility of the symbol groups in stencil.

    Declaration
    public Visibility HeaderVisibility { get; set; }
    Property Value
    Type Description
    System.Windows.Visibility

    ItemAddingCommand

    Occurs before an item is added to the Stencil.

    Declaration
    public ICommand ItemAddingCommand { get; set; }
    Property Value
    Type Description
    System.Windows.Input.ICommand

    ItemDeletingCommand

    Occurs before an item is deleted from the Stencil.

    Declaration
    public ICommand ItemDeletingCommand { get; set; }
    Property Value
    Type Description
    System.Windows.Input.ICommand

    KnownTypes

    Gets or sets a collection of known types that may be present in the stencil for serialization.

    Declaration
    public GetTypes KnownTypes { get; set; }
    Property Value
    Type Description
    GetTypes

    Menu

    Gets or sets the additional menu items for context menu.

    Declaration
    public DiagramMenu Menu { get; set; }
    Property Value
    Type Description
    DiagramMenu

    MenuItemClickedCommand

    Occurs when a menu item is clicked.

    Declaration
    public ICommand MenuItemClickedCommand { get; set; }
    Property Value
    Type Description
    System.Windows.Input.ICommand

    MenuOpeningCommand

    Occurs when any context menu on the element is opened.

    Declaration
    public ICommand MenuOpeningCommand { get; set; }
    Property Value
    Type Description
    System.Windows.Input.ICommand

    SelectedFilter

    Gets or sets a filter from the colloection the SymbolFilters in stencil.

    Declaration
    public SymbolFilterProvider SelectedFilter { get; set; }
    Property Value
    Type Description
    SymbolFilterProvider

    SelectedItems

    Gets or sets the selected items of the Syncfusion.UI.Xaml.Diagram.Stencil.

    Declaration
    public SymbolCollection SelectedItems { get; set; }
    Property Value
    Type Description
    SymbolCollection

    SelectedSymbol

    Gets or sets a selected symbol in stencil.

    Declaration
    public Symbol SelectedSymbol { get; set; }
    Property Value
    Type Description
    Symbol

    SelectionChangedCommand

    Occurs when the selection changes (new items are selected, or currently selected items are unselected).

    Declaration
    public ICommand SelectionChangedCommand { get; set; }
    Property Value
    Type Description
    System.Windows.Input.ICommand

    ShowDisplayModeToggleButton

    Gets or sets the value indicates whether to show/hide the display mode toggle button. The default value is true.

    Declaration
    public bool ShowDisplayModeToggleButton { get; set; }
    Property Value
    Type Description
    System.Boolean
    Examples
     <syncfusion:Stencil x:Name="stencil" Width="250" Title="Stencil Shapes"  ShowDisplayModeToggleButton="false" >
         <!--Initialize the SymbolSource-->
          <syncfusion:Stencil.SymbolSource>               
           <!--Define the SymbolCollection-->
                   <syncfusion:SymbolCollection>
                     <syncfusion:NodeViewModel Key = "Basic Shapes" Name="Triangle" OffsetX="100" OffsetY="100" UnitHeight="100" UnitWidth="100"  Shape="{StaticResource Triangle}" ShapeStyle="{StaticResource nodestyle}" >
                    </syncfusion:NodeViewModel>
                    </syncfusion:SymbolCollection>
                </syncfusion:Stencil.SymbolSource>
            <syncfusion:Stencil.SymbolGroups>
                <syncfusion:SymbolGroups>
                    <!--Separate groups based on the key-->
               <syncfusion:SymbolGroupProvider MappingName = "Key" />
              </ syncfusion:SymbolGroups>
            </syncfusion:Stencil.SymbolGroups>
          </syncfusion:Stencil>

    ShowSearchTextBox

    Gets or sets value indicates whether to display the symbol search textbox in the Stencil.

    Declaration
    public bool ShowSearchTextBox { get; set; }
    Property Value
    Type Description
    System.Boolean

    true to show the search textbox in stencil;Otherwise false. The default value is set to true.

    Examples

    Below example shows how to enable the search textbox in stencil.

     <syncfusion:Stencil x:Name="stencil" Width="250" ExpandMode="All"  ShowSearchTextBox="True">
         <!--Initialize the SymbolSource-->
          <syncfusion:Stencil.SymbolSource>               
           <!--Define the SymbolCollection-->
                   <syncfusion:SymbolCollection>
                     <syncfusion:NodeViewModel Key = "Basic Shapes" Name="Triangle" OffsetX="100" OffsetY="100" UnitHeight="100" UnitWidth="100"  Shape="{StaticResource Triangle}" ShapeStyle="{StaticResource nodestyle}" >
                    </syncfusion:NodeViewModel>
                    </syncfusion:SymbolCollection>
                </syncfusion:Stencil.SymbolSource>
            <syncfusion:Stencil.SymbolGroups>
                <syncfusion:SymbolGroups>
                    <!--Separate groups based on the key-->
               <syncfusion:SymbolGroupProvider MappingName = "Key" />
              </ syncfusion:SymbolGroups>
            </syncfusion:Stencil.SymbolGroups>
          </syncfusion:Stencil>

    SymbolFilterDisplayMode

    Gets or sets value indicates how the SymbolGroupHeader should be displayed. The default value is set to ComboBox.

    Declaration
    public SymbolFilterDisplayMode SymbolFilterDisplayMode { get; set; }
    Property Value
    Type Description
    SymbolFilterDisplayMode
    Remarks

    The display mode can be either ComboBox or List

    Examples

    Below example shows how to enable the SymbolFilterDisplayMode as List. #MainWindow.xaml

    <Window.DataContext>
    <local:StencilVM></local:StencilVM>
    </Window.DataContext>
     <syncfusion:Stencil x:Name="stencil" Width="250"  Title="Stencil Shapes" SymbolFilterDisplayMode="List"   SymbolFilters="{Binding Symbolfilters}" SelectedFilter="{Binding Selectedfilter}">
         <!--Initialize the SymbolSource-->
          <syncfusion:Stencil.SymbolSource>               
           <!--Define the SymbolCollection-->
                   <syncfusion:SymbolCollection>
                     <syncfusion:NodeViewModel Key = "Basic Shapes" Name="Triangle" OffsetX="100" OffsetY="100" UnitHeight="100" UnitWidth="100"  Shape="{StaticResource Triangle}" ShapeStyle="{StaticResource nodestyle}" >
                    </syncfusion:NodeViewModel>
                    </syncfusion:SymbolCollection>
                </syncfusion:Stencil.SymbolSource>
            <syncfusion:Stencil.SymbolGroups>
                <syncfusion:SymbolGroups>
                    <!--Separate groups based on the key-->
               <syncfusion:SymbolGroupProvider MappingName = "Key" />
              </ syncfusion:SymbolGroups>
            </syncfusion:Stencil.SymbolGroups>
          </syncfusion:Stencil>

    #ViewModel.cs

       public class StencilVM : INotifyPropertyChanged
    {
       public StencilVM()
       {
           Symbolfilters = new SymbolFilters();
           SymbolFilterProvider node1 = new SymbolFilterProvider { Content = "Basic Shapes",IsChecked=true, SymbolFilter = Filter };
           this.Symbolfilters.Add(node1);
           this.Selectedfilter = Symbolfilters[0];
       }
      //Define filtering of Symbols
       private bool Filter(SymbolFilterProvider sender, object symbol)
       {
           if (symbol is NodeViewModel)
           {
               if (sender.Content.ToString() == (symbol as NodeViewModel).Key.ToString())
                   return true;
           }
           return false;
       }
       public ObservableCollection<SymbolFilterProvider> Symbolfilters { get; set; }
       public SymbolFilterProvider Selectedfilter { get; set; }
       public event PropertyChangedEventHandler PropertyChanged;
    }

    SymbolFilters

    Gets or sets a collection used to generate the SymbolFilters in stencil.

    Declaration
    public SymbolFilters SymbolFilters { get; set; }
    Property Value
    Type Description
    SymbolFilters
    Examples

    Below code example shows how to define the symbol filter in the stencil

           public class StencilVM : INotifyPropertyChanged
       {
           public StencilVM()
           {
           Symbolfilters = new SymbolFilters();
           SymbolFilterProvider all = new SymbolFilterProvider { Content = "All", SymbolFilter = Filter };
           SymbolFilterProvider Node = new SymbolFilterProvider { Content = "Nodes", SymbolFilter = Filter };
           SymbolFilterProvider Con = new SymbolFilterProvider { Content = "Connector", SymbolFilter = Filter };
    
               this.Symbolfilters.Add(all);
               this.Symbolfilters.Add(Node);
               this.Symbolfilters.Add(Con);
               this.Selectedfilter = Symbolfilters[0];
       }
    
           // Define filtering of Symbols
           private bool Filter(SymbolFilterProvider sender, object symbol)
           {
               if (symbol is NodeViewModel)
               {
                   if (sender.Content.ToString() == (symbol as NodeViewModel).Key.ToString())
                       return true;
       }
    
               if (symbol is ConnectorViewModel)
               {
                   if (sender.Content.ToString() == (symbol as ConnectorViewModel).Key.ToString())
                       return true;
       }
               if (sender.Content.ToString() == "All")
               {
                   return true;
       }
               return false;
       }
           public ObservableCollection<SymbolFilterProvider> Symbolfilters { get; set; }
    
           public SymbolFilterProvider Selectedfilter { get; set; }
    
           public event PropertyChangedEventHandler PropertyChanged;
       }
       }

    SymbolGroups

    Gets or sets a collection used to generate the SymbolGroupProvider in stencil.

    Declaration
    public SymbolGroups SymbolGroups { get; set; }
    Property Value
    Type Description
    SymbolGroups
    Examples

    Below example shows how to group the symbols in the stencil. #MainWindow.xaml

    <stencil:Stencil Grid.Column="0" BorderThickness="1" BorderBrush="#dfdfdf" x:Name="stencil">
       <!--Initialize the SymbolSource-->
       <stencil:Stencil.SymbolSource>
       <!--Define the SymbolCollection-->
       <local:SymbolCollection>
           <syncfusion:NodeViewModel x:Name="node" UnitHeight="70" UnitWidth="100" OffsetX="100" OffsetY="100" Shape="{StaticResource Rectangle}" Key="Node">
           </syncfusion:NodeViewModel>
           <syncfusion:ConnectorViewModel SourcePoint = "100,100" TargetPoint="200,200" Key="Connector"/>
           <!--Define the DiagramElement- Group-->
           <syncfusion:GroupViewModel Key = "Group" >
               < !--Creates the Groupable Nodes-->
               <syncfusion:GroupViewModel.Nodes>
                   <syncfusion:NodeCollection>
                       <syncfusion:NodeViewModel UnitHeight = "70" ID="srcnode" OffsetX="0" OffsetY="300" UnitWidth="100" Shape="{StaticResource Rectangle}"></syncfusion:NodeViewModel>
                       <syncfusion:NodeViewModel UnitHeight = "70"        ID="tarnode" OffsetX="100" OffsetY="500" UnitWidth="100" Shape="{StaticResource Rectangle}"></syncfusion:NodeViewModel>
                   </syncfusion:NodeCollection>
               </syncfusion:GroupViewModel.Nodes>
               <!--Creates the Groupable Connectors-->
               <syncfusion:GroupViewModel.Connectors>
                   <syncfusion:ConnectorCollection>
                       <syncfusion:ConnectorViewModel SourceNodeID = "srcnode" TargetNodeID="tarnode"/>
                   </syncfusion:ConnectorCollection>
               </syncfusion:GroupViewModel.Connectors>
           </syncfusion:GroupViewModel>
       </local:SymbolCollection>
    </stencil:Stencil.SymbolSource>
       <!--Initialize the SymbolGroup-->
       <stencil:Stencil.SymbolGroups>
           <stencil:SymbolGroups>
               <!--Map Symbols Using MappingName-->
               <stencil:SymbolGroupProvider MappingName = "Key" >
               </ stencil:SymbolGroupProvider>
           </stencil:SymbolGroups>
       </stencil:Stencil.SymbolGroups>
    </stencil:Stencil>

    #MainWindow.xaml.cs

       //Collection of Symbols
       public class SymbolCollection : ObservableCollection<object>
       {
    
       }

    SymbolPreview

    Gets or sets the preview of symbol when drag from stencil.

    Declaration
    public ContentPresenter SymbolPreview { get; set; }
    Property Value
    Type Description
    System.Windows.Controls.ContentPresenter

    SymbolsDisplayMode

    Gets or sets a value indicates how the symbols should be displayed in the Syncfusion.UI.Xaml.Diagram.Stencil. The default is IconsOnly.

    Declaration
    public SymbolsDisplayMode SymbolsDisplayMode { get; set; }
    Property Value
    Type Description
    SymbolsDisplayMode
    See Also
    SymbolsDisplayMode

    SymbolSource

    Gets or sets a collection used to generate the symbol in stencil.

    Declaration
    public object SymbolSource { get; set; }
    Property Value
    Type Description
    System.Object
    Examples

    #MainWindow.xaml

    <!--Initialize the SymbolSource-->
    <stencil:Stencil.SymbolSource>
        <!--Define the SymbolCollection-->
        <local:SymbolCollection>
           <Syncfusion:SymbolViewModel Symbol = "User" SymbolTemplate="{StaticResource symboltemplate}"/>
            <syncfusion:NodeViewModel x:Name="node" UnitHeight="70" UnitWidth="100" OffsetX="100" OffsetY="100" Shape="{StaticResource Rectangle}">
            </syncfusion:NodeViewModel>
            <syncfusion:ConnectorViewModel SourcePoint = "100,100" TargetPoint="200,200"/>
            <!--Define the DiagramElement- Group-->
            <syncfusion:GroupViewModel>
                <!--Creates the Groupable Nodes-->
                <syncfusion:GroupViewModel.Nodes>
                    <syncfusion:NodeCollection>
                        <syncfusion:NodeViewModel UnitHeight = "70" ID="srcnode" OffsetX="0" OffsetY="300" UnitWidth="100" Shape="{StaticResource Rectangle}"> </syncfusion:NodeViewModel>
                        <syncfusion:NodeViewModel UnitHeight = "70" ID="tarnode" OffsetX="100" OffsetY="500" UnitWidth="100" Shape="{StaticResource Rectangle}"> </syncfusion:NodeViewModel>
                   </syncfusion:NodeCollection>
               </syncfusion:GroupViewModel.Nodes>
               <!--Creates the Groupable Connectors-->
               <syncfusion:GroupViewModel.Connectors>
                   <syncfusion:ConnectorCollection>
                       <syncfusion:ConnectorViewModel SourceNodeID = "srcnode" TargetNodeID="tarnode"/>
                   </syncfusion:ConnectorCollection>
               </syncfusion:GroupViewModel.Connectors>
           </syncfusion:GroupViewModel>
       </local:SymbolCollection>
    </stencil:Stencil.SymbolSource>

    #MainWindow.xaml.cs

    //Collection of Symbols
    public class SymbolCollection : ObservableCollection<object>
    {
    }

    Title

    Gets or sets the title of the Stencil. The default title is null.

    Declaration
    public object Title { get; set; }
    Property Value
    Type Description
    System.Object
    Examples
    <syncfusion:Stencil x:Name="stencil" Width="250" ExpandMode="All" Title="Stencil Shapes">
         <!--Initialize the SymbolSource-->
          <syncfusion:Stencil.SymbolSource>               
           <!--Define the SymbolCollection-->
                   <syncfusion:SymbolCollection>
                     <syncfusion:NodeViewModel Key = "Basic Shapes" Name="Triangle" OffsetX="100" OffsetY="100" UnitHeight="100" UnitWidth="100"  Shape="{StaticResource Triangle}" ShapeStyle="{StaticResource nodestyle}" >
                    </syncfusion:NodeViewModel>
                    </syncfusion:SymbolCollection>
                </syncfusion:Stencil.SymbolSource>
            <syncfusion:Stencil.SymbolGroups>
                <syncfusion:SymbolGroups>
                    <!--Separate groups based on the key-->
               <syncfusion:SymbolGroupProvider MappingName = "Key" />
              </ syncfusion:SymbolGroups>
            </syncfusion:Stencil.SymbolGroups>
          </syncfusion:Stencil>

    TitleTemplate

    Gets or sets the title template used to display the title of the Stencil.

    Declaration
    public DataTemplate TitleTemplate { get; set; }
    Property Value
    Type Description
    System.Windows.DataTemplate
    Examples
    <DataTemplate x:Key="TitleTemplate">
    <TextBlock Text="{Binding}" Foreground="Black" FontSize="14" ></TextBlock>
    </DataTemplate>
     <syncfusion:Stencil x:Name="stencil" Width="250" ExpandMode="All" Title="Stencil Shapes" TitleTemplate="{StaticResource TitleTemplate}"  >
         <!--Initialize the SymbolSource-->
          <syncfusion:Stencil.SymbolSource>               
           <!--Define the SymbolCollection-->
                   <syncfusion:SymbolCollection>
                     <syncfusion:NodeViewModel Key = "Basic Shapes" Name="Triangle" OffsetX="100" OffsetY="100" UnitHeight="100" UnitWidth="100"  Shape="{StaticResource Triangle}" ShapeStyle="{StaticResource nodestyle}" >
                    </syncfusion:NodeViewModel>
                    </syncfusion:SymbolCollection>
                </syncfusion:Stencil.SymbolSource>
            <syncfusion:Stencil.SymbolGroups>
                <syncfusion:SymbolGroups>
                    <!--Separate groups based on the key-->
               <syncfusion:SymbolGroupProvider MappingName = "Key" />
              </ syncfusion:SymbolGroups>
            </syncfusion:Stencil.SymbolGroups>
          </syncfusion:Stencil>

    Methods

    CacheContextMenuforItemOverride(ContextMenu)

    Store the System.Windows.Controls.ContextMenu element to stack for recycling.

    Declaration
    protected virtual void CacheContextMenuforItemOverride(ContextMenu view)
    Parameters
    Type Name Description
    System.Windows.Controls.ContextMenu view

    Store the view instance to stack for recycling.

    CacheMenuItemforItemsOverride(MenuItem)

    Store the System.Windows.Controls.MenuItem element to stack for recycling.

    Declaration
    protected virtual void CacheMenuItemforItemsOverride(MenuItem view)
    Parameters
    Type Name Description
    System.Windows.Controls.MenuItem view

    Parameter to store the menuitem instance to stack for recycling.

    CanAddSymbol(String, String)

    Virtual method to decide whether the symbol can be added into collection or not.

    Declaration
    protected virtual bool CanAddSymbol(string SymbolName, string CategoryName)
    Parameters
    Type Name Description
    System.String SymbolName

    Name of the symbol.

    System.String CategoryName

    Name of the symbol category.

    Returns
    Type Description
    System.Boolean

    Returns the bool.

    Remarks

    This virtual method is applicable only when category collection is provided.

    GetContextMenuForItemOverride()

    Creates or identifies the view that is used to display the ContextMenu.

    Declaration
    protected virtual ContextMenu GetContextMenuForItemOverride()
    Returns
    Type Description
    System.Windows.Controls.ContextMenu

    Returns a instance of ContextMenu.

    GetMenuItemForItemsOverride()

    Creates or identifies the view that is used to display the ContextMenu Item.

    Declaration
    protected virtual MenuItem GetMenuItemForItemsOverride()
    Returns
    Type Description
    System.Windows.Controls.MenuItem

    Returns a instance of MenuItem.

    GetSymbolForItemOverride(Object)

    Creates the view that is used to represent the given symbol.

    Declaration
    public virtual Symbol GetSymbolForItemOverride(object item)
    Parameters
    Type Name Description
    System.Object item
    Returns
    Type Description
    Symbol

    GetSymbolGroupForItemOverride(Object)

    Creates the view that is used to represent the given symbol group.

    Declaration
    public virtual SymbolGroup GetSymbolGroupForItemOverride(object item)
    Parameters
    Type Name Description
    System.Object item
    Returns
    Type Description
    SymbolGroup

    Load(Stream)

    Loading the existing saved stencil from the data stream.

    Declaration
    public void Load(Stream stream)
    Parameters
    Type Name Description
    System.IO.Stream stream

    A System.IO.Stream that contains the data for this Stencil.

    OnApplyTemplate()

    When overridden in a derived class, is invoked whenever application code or internal processes call System.Windows.FrameworkElement.ApplyTemplate.

    Declaration
    public override void OnApplyTemplate()

    OnCreateAutomationPeer()

    Declaration
    protected override AutomationPeer OnCreateAutomationPeer()
    Returns
    Type Description
    System.Windows.Automation.Peers.AutomationPeer

    OnSymbolsLoaded(SymbolsLoadedEventArgs)

    Invokd when symbols are loaded into stencil.

    Declaration
    public void OnSymbolsLoaded(SymbolsLoadedEventArgs args)
    Parameters
    Type Name Description
    SymbolsLoadedEventArgs args

    Data for loaded symbols.

    PrepareDragDropPreview()

    Method to customize the preview of symbol while dropping.

    Declaration
    protected virtual void PrepareDragDropPreview()

    PrepareSymbolViewModel(Object, String, String)

    Virtual method to override the default category collection, customize the symbol and its values.

    Declaration
    protected virtual object PrepareSymbolViewModel(object Item, string SymbolName, string CategoryName)
    Parameters
    Type Name Description
    System.Object Item

    Symbol of the collection

    System.String SymbolName

    Name of the symbol

    System.String CategoryName

    name of the symnol category

    Returns
    Type Description
    System.Object

    Returns the symbol of the collection

    Remarks

    This virtual method is applicable only when category collection is provided.

    Save(Stream)

    Saves this Stencil to the specified stream.

    Declaration
    public void Save(Stream stream)
    Parameters
    Type Name Description
    System.IO.Stream stream

    The Stream where the stencil will be saved..

    SearchSymbol(String)

    Search a specific symbol in stencil.

    Declaration
    public void SearchSymbol(string str)
    Parameters
    Type Name Description
    System.String str

    Symbol key.

    Events

    Collapsed

    Occurs when collapse the symbol group.

    Declaration
    public event SymbolGroupCollapseEventHandler Collapsed
    Event Type
    Type Description
    SymbolGroupCollapseEventHandler

    Expanded

    Occurs when expand the symbol group.

    Declaration
    public event SymbolGroupExpandEventHandler Expanded
    Event Type
    Type Description
    SymbolGroupExpandEventHandler

    ItemAdding

    Occurs before an item is added to the Stencil.

    Declaration
    public event ItemAddingEventHandler ItemAdding
    Event Type
    Type Description
    ItemAddingEventHandler

    ItemDeleting

    Occurs before an item is deleted from the Stencil.

    Declaration
    public event ItemDeletingEventHandler ItemDeleting
    Event Type
    Type Description
    ItemDeletingEventHandler

    MenuItemClicked

    Occurs when a menu item is clicked.

    Declaration
    public event MenuItemClickedEventHander MenuItemClicked
    Event Type
    Type Description
    MenuItemClickedEventHander

    MenuOpening

    Occurs when any context menu on the element is opened.

    Declaration
    public event MenuOpeningEventHandler MenuOpening
    Event Type
    Type Description
    MenuOpeningEventHandler

    SelectionChanged

    Occurs when the selection changes (new items are selected, or currently selected items are unselected).

    Declaration
    public event SelectionChangedEventHandler SelectionChanged
    Event Type
    Type Description
    SelectionChangedEventHandler

    SymbolsLoaded

    Occurs when the symbol is laid out, rendered, and ready for interaction

    Declaration
    public event SymbolsLoadedEventHandler SymbolsLoaded
    Event Type
    Type Description
    SymbolsLoadedEventHandler
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved