コード例 #1
0
        // drop method
        public void Drop
        (
            FrameworkElement draggedAndDroppedElement,
            FrameworkElement dropContainer,
            Point mousePositionWithRespectToContainer)
        {
            // get the dragged/dropped element's view model
            NumberVm droppedVm =
                draggedAndDroppedElement.DataContext as NumberVm;

            // get the drop container's view model
            TestVm testVm =
                dropContainer.DataContext as TestVm;

            // create the inserted glyph's view model
            // note that the last constructor argument
            // specifies the glyph's position within
            // the drop container.
            NumberVmWithPostion newGlyphVm = new NumberVmWithPostion
                                             (
                droppedVm.Number,
                droppedVm.NumStr,
                mousePositionWithRespectToContainer.ToPoint2D());

            // insert the new glyph into the Glyphs collection
            // of the view model
            testVm.Glyphs.Add(newGlyphVm);
        }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();

            DataContext = new TestVm();
        }