This is a migrated thread and some comments may be shown as answers.

Restricting Diagram shapes from going out of the diagram constrained area

3 Answers 39 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Yogendra
Top achievements
Rank 1
Yogendra asked on 19 Sep 2013, 01:25 PM
Hi,

I have set the width and height of the diagram control. Now can you please help in letting me know how to restrict the Diagram shape that I now dropped in the diagram area to move within this constraint area only. Please suggest something.

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 24 Sep 2013, 07:25 AM
Hi Yogendra,

I am happy to inform you that the RadDiagram exposes services that can be used to achieve your goal. You can find ready to run project in our XAML SDK where we demonstrated how you can implement custom service.

Please take a look at the project and let us know if you need any further assistance.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Yogendra
Top achievements
Rank 1
answered on 17 Oct 2013, 12:34 PM
Thanks your reply back.

Your solution is working with mouse but i can change the left, top, width and height from numeric up down button, and values are bounded  with property. Code is here:-

Private m_shapeWidth As Double
  Public Property ShapeWidth() As Double
      Get
          Return m_shapeWidth
      End Get
      Set(ByVal value As Double)
          m_shapeWidth = value
         
          Me.OnPropertyChanged("ShapeWidth")
          If SelectedItem IsNot Nothing Then
              SelectedItem.Width = ShapeWidth
          End If
      End Set
  End Property
 
  Private m_shapeHeight As Double
  Public Property ShapeHeight() As Double
      Get
          Return m_shapeHeight
      End Get
      Set(ByVal value As Double)
          m_shapeHeight = value
          Me.OnPropertyChanged("ShapeHeight")
          If SelectedItem IsNot Nothing Then
              SelectedItem.Height = ShapeHeight
          End If
      End Set
  End Property

when i changing width, height, left and top from numeric updown button, shape does not restrict within constraint area.

Thanks in advanced.
0
Pavel R. Pavlov
Telerik team
answered on 22 Oct 2013, 11:45 AM
Hi Yogendra,

You are right that the provided custom service is working when the the shapes are being moved using the mouse. In order to implement such restriction whenever the Position (or any other) property is being changed you can check the value of the property exposed by your ViewModel before changing it.

For example lets take the Width property in your ViewModel. Lets say that it should not be greater than 90 pixels. Hence, you can change it only when the Value in the setter of that property is lower than 90, if equal or greater you can set it to 90.

In other words - when using MVVM approach you can implement custom logic in your ViewModel to verify that the properties (Position, Height, Width...) are in the desired range.

Please give this approach a try and let us know if you have any other questions.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Diagram
Asked by
Yogendra
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Yogendra
Top achievements
Rank 1
Share this question
or