Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to save a Canvas which is in the ItemsControl?

$
0
0

Here is my Canvas:

<ItemsControl x:Name="ic" ItemsSource="{Binding NozzleCanvasNBD_}"><ItemsControl.Resources><DataTemplate DataType="{x:Type c:CircleVM}"><Ellipse Stroke="Red" Fill="White" Width="{Binding EllipseWidth,Mode=TwoWay}" Height="{Binding EllipseHeight,Mode=TwoWay}"/></DataTemplate><DataTemplate DataType="{x:Type c:TextBlockVM}"><TextBlock Text="{Binding TbText}"/></DataTemplate><DataTemplate DataType="{x:Type c:LineVM}"><Line Stroke="Green" StrokeDashArray="{Binding StrokeDashArray}" X1="{Binding X1}" X2="{Binding X2}" Y1="{Binding Y1}" Y2="{Binding Y2}"/></DataTemplate></ItemsControl.Resources><ItemsControl.ItemsPanel><ItemsPanelTemplate><Canvas Width="{Binding NozzleCanvasNBDWidth}" Height="{Binding NozzleCanvasNBDHeight}"/></ItemsPanelTemplate></ItemsControl.ItemsPanel><ItemsControl.ItemContainerStyle><Style TargetType="ContentPresenter"><Setter Property="Canvas.Top" Value="{Binding Top}"/><Setter Property="Canvas.Left" Value="{Binding Left}"/></Style></ItemsControl.ItemContainerStyle></ItemsControl>

Before I used to do like so:

            string key = "Nozzles on Bottom Dish Drawing";
            if (drawings.ContainsKey(key))
                drawings[key] = NozzleCanvasNBD_;
            else
                drawings.Add("Nozzles on Bottom Dish Drawing", NozzleCanvasNBD_);

  public Dictionary<string, Canvas> drawings = new Dictionary<string, Canvas>();

Obviously, I can't do it in this way anymore because I'm using mvvm pattern. But, how could I do, now?


Viewing all articles
Browse latest Browse all 18858


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>