or



<!-- ID --><t:DataFormDataField Label="ID" Description="Todo" DataMemberBinding="{Binding ID, Mode=OneWay}"> <t:DataFormDataField.Content> <t:RadWatermarkTextBox Text="{Binding ID, Mode=OneWay}" IsReadOnly="True" /> </t:DataFormDataField.Content></t:DataFormDataField><!-- Name --><t:DataFormDataField Label="Name" Description="Todo" DataMemberBinding="{Binding Name, Mode=TwoWay, NotifyOnValidationError=True}"> <t:DataFormDataField.Content> <t:RadWatermarkTextBox Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" WatermarkContent="Please fill in your name" /> </t:DataFormDataField.Content></t:DataFormDataField><!-- DYNAMIC DATA FIELDS --><ItemsControl ItemsSource="{Binding Source={StaticResource CollectionViewSource}}" Focusable="False"> <ItemsControl.ItemTemplateSelector> <v:MyDataTemplateSelector> <!-- Text DataTemplate (Value is string so show it in DataFormDataField) --> <v:MyDataTemplateSelector.TextBoxDataTemplate> <DataTemplate> <t:DataFormDataField Label="{Binding Label, Mode=OneWay}" Description="{Binding ToolTip, Mode=OneWay}" DataMemberBinding="{Binding Value, Mode=TwoWay, NotifyOnValidationError=True}"> <t:DataFormDataField.Content> <t:RadWatermarkTextBox Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" WatermarkContent="Please insert value" /> </t:DataFormDataField.Content> </t:DataFormDataField> </DataTemplate> </v:MyDataTemplateSelector.TextBoxDataTemplate> <!-- Date DataTemplate (Value is datetime so show it as DataFormDateField) --> <v:MyDataTemplateSelector.DateDataTemplate> <DataTemplate> <t:DataFormDateField Label="{Binding Label, Mode=OneWay}" Description="{Binding ToolTip, Mode=OneWay}" DataMemberBinding="{Binding Value, Mode=TwoWay, NotifyOnValidationError=True}"> <t:DataFormDateField.Content> <t:RadDatePicker DateSelectionMode="Year" SelectedValue="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> </t:DataFormDateField.Content> </t:DataFormDateField> </DataTemplate> </v:MyDataTemplateSelector.DateDataTemplate> <!-- More DataTemplates here ... --> </v:MyDataTemplateSelector> </ItemsControl.ItemTemplateSelector></ItemsControl>public class PolylineShapeTool : ToolBase, IMouseListener { private LineSegment _currentLineSegment; private PathFigure _currentPathFigure; private PathSegmentCollection _currentPathSegmentCollection; private RadDiagramShape _currentShape; public PolylineShapeTool() : base("PolylineShapeTool") { } private RadDiagram Diagram { get { return Graph as RadDiagram; } } public bool MouseDown(PointerArgs e) { return false; } public bool MouseDoubleClick(PointerArgs e) { return false; } public bool MouseMove(PointerArgs e) { if (IsActive && _currentShape != null) { if (_currentLineSegment != null) { var rect = CalculateRectFromBasePoint(e.TransformedPoint); _currentLineSegment.Point = e.TransformedPoint; _currentShape.Width = rect.Width; _currentShape.Height = rect.Height; } return true; } return false; } public bool MouseUp(PointerArgs e) { if (IsActive) { _currentLineSegment = new LineSegment { Point = e.TransformedPoint }; if (_currentPathSegmentCollection == null) { _currentPathSegmentCollection = new PathSegmentCollection(); _currentPathFigure = new PathFigure { StartPoint = e.TransformedPoint, Segments = _currentPathSegmentCollection, IsFilled = false, IsClosed = false }; var pathGeometry = new PathGeometry { Figures = new PathFigureCollection { _currentPathFigure } }; _currentShape = new RadDiagramShape { Geometry = pathGeometry}; Diagram.AddShape(_currentShape); } _currentPathSegmentCollection.Add(_currentLineSegment); _currentPathFigure.Segments = _currentPathSegmentCollection; return true; } return false; } protected override void OnDeactivated() { base.OnDeactivated(); _currentShape = null; _currentLineSegment = null; _currentPathFigure = null; _currentPathSegmentCollection = null; } private Rect CalculateRectFromBasePoint(Point transformedPoint) { var width = Math.Abs(_currentShape.X - transformedPoint.X); var height = Math.Abs(_currentShape.Y - transformedPoint.Y); var x = Math.Min(_currentShape.X, transformedPoint.X); var y = Math.Min(_currentShape.Y, transformedPoint.Y); return new Rect(x, y, width, height); } }