Class Stencil
Represents the library of shapes.
Inheritance
Namespace: Syncfusion.UI.Xaml.Diagram.Stencil
Assembly: Syncfusion.SfDiagram.UWP.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 |
---|
Windows.UI.Xaml.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 |
---|
Windows.UI.Xaml.DependencyProperty |
DiagramThemeProperty
Identifies the DiagramTheme dependency property.
Declaration
public static DependencyProperty DiagramThemeProperty
Field Value
Type |
---|
Windows.UI.Xaml.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 |
---|
Windows.UI.Xaml.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 |
---|
Windows.UI.Xaml.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 |
---|
Windows.UI.Xaml.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 |
---|
Windows.UI.Xaml.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 |
---|
Windows.UI.Xaml.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 |
---|
Windows.UI.Xaml.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 |
---|
Windows.UI.Xaml.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 |
---|
Windows.UI.Xaml.DependencyProperty |
SymbolSelectionModeProperty
Using a DependencyProperty as the backing store for SymbolSelectionMode property. This enables selection mode for stencil elements.
Declaration
public static DependencyProperty SymbolSelectionModeProperty
Field Value
Type |
---|
Windows.UI.Xaml.DependencyProperty |
SymbolSourceProperty
Identifies the Syncfusion.UI.Xaml.Diagram.Stencil.SymbolSource dependency property.
Declaration
public static DependencyProperty SymbolSourceProperty
Field Value
Type |
---|
Windows.UI.Xaml.DependencyProperty |
Properties
Categories
Gets or sets the stencil groups collection.
Declaration
public StencilCategoryCollection Categories { get; set; }
Property Value
Type |
---|
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 |
---|
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 |
---|
DiagramTheme |
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 |
---|
ExpandMode |
Remarks
This is applicable only for the
HeaderVisibility
Gets or sets the header visibility of the symbol groups in stencil.
Declaration
public Visibility HeaderVisibility { get; set; }
Property Value
Type |
---|
Windows.UI.Xaml.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 |
---|
GetTypes |
SelectedFilter
Gets or sets a filter from the colloection the SymbolFilters in stencil.
Declaration
public SymbolFilterProvider SelectedFilter { get; set; }
Property Value
Type |
---|
SymbolFilterProvider |
SelectedSymbol
Gets or sets a selected symbol in stencil.
Declaration
public Symbol SelectedSymbol { get; set; }
Property Value
Type |
---|
Symbol |
SymbolFilters
Gets or sets a collection used to generate the SymbolFilters in stencil.
Declaration
public SymbolFilters SymbolFilters { get; set; }
Property Value
Type |
---|
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 |
---|
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 |
---|
Windows.UI.Xaml.Controls.ContentPresenter |
SymbolSelectionMode
Gets or sets a value that indicates the selection mode of the symbols in stencil is single or multiple.
Declaration
public SymbolSelectionMode SymbolSelectionMode { get; set; }
Property Value
Type |
---|
SymbolSelectionMode |
SymbolSource
Gets or sets a collection used to generate the symbol in stencil.
Declaration
public object SymbolSource { get; set; }
Property Value
Type |
---|
System.Object |
Examples
<!--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>
//Collection of Symbols
public class SymbolCollection : ObservableCollection<object>
{
}
Methods
add_Collapsed(SymbolGroupCollapseEventHandler)
Declaration
public void add_Collapsed(SymbolGroupCollapseEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
SymbolGroupCollapseEventHandler | value |
add_Expanded(SymbolGroupExpandEventHandler)
Declaration
public void add_Expanded(SymbolGroupExpandEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
SymbolGroupExpandEventHandler | value |
add_SymbolsLoaded(SymbolsLoadedEventHandler)
Declaration
public void add_SymbolsLoaded(SymbolsLoadedEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
SymbolsLoadedEventHandler | value |
ArrangeOverride(Size)
Declaration
protected override Size ArrangeOverride(Size finalSize)
Parameters
Type | Name | Description |
---|---|---|
Windows.Foundation.Size | finalSize |
Returns
Type |
---|
Windows.Foundation.Size |
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 |
---|
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 |
---|
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()
Declaration
protected 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.
remove_Collapsed(SymbolGroupCollapseEventHandler)
Declaration
public void remove_Collapsed(SymbolGroupCollapseEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
SymbolGroupCollapseEventHandler | value |
remove_Expanded(SymbolGroupExpandEventHandler)
Declaration
public void remove_Expanded(SymbolGroupExpandEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
SymbolGroupExpandEventHandler | value |
remove_SymbolsLoaded(SymbolsLoadedEventHandler)
Declaration
public void remove_SymbolsLoaded(SymbolsLoadedEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
SymbolsLoadedEventHandler | value |
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 |
---|
SymbolGroupCollapseEventHandler |
Expanded
Occurs when expand the symbol group.
Declaration
public event SymbolGroupExpandEventHandler Expanded
Event Type
Type |
---|
SymbolGroupExpandEventHandler |
SymbolsLoaded
Occurs when the symbol is laid out, rendered, and ready for interaction
Declaration
public event SymbolsLoadedEventHandler SymbolsLoaded
Event Type
Type |
---|
SymbolsLoadedEventHandler |