0

Hello stackoverflowers,

I made a class CustomCanvas that inherit from System.Windows.Controls.Canvas. In a ViewModel, i have an instance of CustomCanvas.

I would like to bind the control CustomCanvas in the XAML (see below how i used it in XAML) to the instance of CustomCanvas from the view model in order to have inserts in Canvas.Children displayed on screen. How can i achieve that ?

 <Contents:CanvasCustom 
                        Background="#00000000"
                        x:Name="SuperCanvas"
                        Width="650"
                        Height="450">

 </Contents:CanvasCustom>
Csi
  • 526
  • 3
  • 22
  • 1
    this post: http://stackoverflow.com/questions/7177432/how-to-display-items-in-canvas-through-binding shows a better practive than "an instance of CustomCanvas in a ViewModel" – ASh Aug 29 '16 at 13:44
  • 2
    As per MVVM you should not have a UI control (canvas in your case) in the view model. I will suggest you should reconsider your design. – Versatile Aug 29 '16 at 13:48
  • Following your two comments i changed my design and now have an IList in my view model binded to my custom control which now inherit from ItemControls. – Csi Aug 29 '16 at 13:57

0 Answers0