Class Stencil
Represents the library of shapes.
Inheritance
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
Identifies the Categories property.
Declaration
public static DependencyProperty CategoriesProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
ConstraintsProperty
Identifies the Syncfusion.UI.Xaml.Diagram.Stencil.Constraints dependency property.
Declaration
public static DependencyProperty ConstraintsProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
DisplayModeProperty
Declaration
public static readonly DependencyProperty DisplayModeProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
ExpandModeProperty
Identifies the Syncfusion.UI.Xaml.Diagram.Stencil.ExpandMode dependency property.
Declaration
public static DependencyProperty ExpandModeProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
HeaderVisibilityProperty
Identifies the Syncfusion.UI.Xaml.Diagram.Stencil.HeaderVisibility dependency property.
Declaration
public static DependencyProperty HeaderVisibilityProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
SelectedFilterProperty
Identifies the Syncfusion.UI.Xaml.Diagram.Stencil.SelectedFilter dependency property.
Declaration
public static DependencyProperty SelectedFilterProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
SelectedSymbolProperty
Identifies the Syncfusion.UI.Xaml.Diagram.Stencil.SelectedSymbol dependency property.
Declaration
public static DependencyProperty SelectedSymbolProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
ShowDisplayModeToggleButtonProperty
Declaration
public static readonly DependencyProperty ShowDisplayModeToggleButtonProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
ShowSearchTextBoxProperty
Declaration
public static readonly DependencyProperty ShowSearchTextBoxProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
SymbolFilterDisplayModeProperty
Declaration
public static readonly DependencyProperty SymbolFilterDisplayModeProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
SymbolFiltersProperty
Identifies the Syncfusion.UI.Xaml.Diagram.Stencil.SymbolFilters dependency property.
Declaration
public static DependencyProperty SymbolFiltersProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
SymbolGroupProperty
Declaration
public static DependencyProperty SymbolGroupProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
SymbolGroupsProperty
Identifies the Syncfusion.UI.Xaml.Diagram.Stencil.SymbolGroups dependency property.
Declaration
public static DependencyProperty SymbolGroupsProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
SymbolPreviewProperty
Identifies the Syncfusion.UI.Xaml.Diagram.Stencil.SymbolPreview dependency property.
Declaration
public static DependencyProperty SymbolPreviewProperty
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
Declaration
public static readonly DependencyProperty TitleProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
TitleTemplateProperty
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>
//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 |
DisplayMode
Declaration
public DisplayMode DisplayMode { get; set; }
Property Value
Type | Description |
---|---|
DisplayMode |
ExpandMode
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 |
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 |
SelectedFilter
Gets or sets a filter from the colloection the SymbolFilters in stencil.
Declaration
public SymbolFilterProvider SelectedFilter { get; set; }
Property Value
Type | Description |
---|---|
SymbolFilterProvider |
SelectedSymbol
Gets or sets a selected symbol in stencil.
Declaration
public Symbol SelectedSymbol { get; set; }
Property Value
Type | Description |
---|---|
Symbol |
ShowDisplayModeToggleButton
Declaration
public bool ShowDisplayModeToggleButton { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
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 |
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>
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>
//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 |
SymbolSource
Declaration
public object SymbolSource { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
Title
Declaration
public object Title { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
TitleTemplate
Declaration
public DataTemplate TitleTemplate { get; set; }
Property Value
Type | Description |
---|---|
System.Windows.DataTemplate |
Methods
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.
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)
Declaration
public void Load(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream |
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()
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 |
SymbolsLoaded
Occurs when the symbol is laid out, rendered, and ready for interaction
Declaration
public event SymbolsLoadedEventHandler SymbolsLoaded
Event Type
Type | Description |
---|---|
SymbolsLoadedEventHandler |