Share:

MainWindow.cs | Drag Object To Scroll In WPF C# | Amit Padhiyar | Saatody

MainWindow.cs

Drag object using MouseLeftButtonDown, MouseLeftButtonUp and MouseMove. When we drag object using mouse and if object's any part is going outside parent panel then the parent panel margin automatically update and try to in that object.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace EffectFeatures
{
    public partial class MainWindow : Window
    {
        public static UIElement UI = new UIElement();
        public MainWindow()
        {
            InitializeComponent();
            UI = Container;

            MyRowControl MRC = new MyRowControl();
            MRC.HorizontalAlignment = HorizontalAlignment.Center;
            MRC.VerticalAlignment = VerticalAlignment.Top;
            MRC.Margin = new Thickness(0, 0, 0, 0);
            MRC.Width = 1400;
            MRC.Height = 100;
            MRC.Background = new SolidColorBrush(Color.FromRgb(240, 240, 240));
            Container.Children.Add(MRC);
            MRC.Initialize();

            MyRowTest MRT = new MyRowTest();
            MRT.HorizontalAlignment = HorizontalAlignment.Center;
            MRT.VerticalAlignment = VerticalAlignment.Top;
            MRT.Margin = new Thickness(0, 100, 0, 0);
            MRT.Width = 1400;
            MRT.Height = 700;
            MRT.Background = new SolidColorBrush(Color.FromRgb(0, 0, 0));
            Container.Children.Add(MRT);
            MRT.Initialize();
        }
    }
}

Comments

Popular posts from this blog

Get Color From Pixel C# WPF | Saatody | Amit Padhiyar

Basic Audio Operations With MP3 And Wave Files Using NAudio C#

Create Drag And Drop Operation Between DevExpress GridControl And Custom WPF UI | Saatody | Amit Padhiyar