RightEffect.cs | Drag Object To Scroll In WPF C# | Amit Padhiyar | Saatody
RightEffect.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.Windows; using System.Windows.Controls; using System.Windows.Shapes; using System.Windows.Media; using System.Windows.Input; namespace EffectFeatures { public class RightEffect : Border { public void Initialize() { try { Repaint(); Resize(); Event(); Refresh(); } catch (Exception e) { } } public void Repaint() { try { this.Background = new SolidColorBrush(Color.FromArgb(100, 255, 165, 0)); this.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 255, 165, 0)); this.BorderThickness = new Thickness(2); this.CornerRadius = new CornerRadius(5, 5, 5, 5); } catch (Exception e) { } } public void Resize() { try { this.HorizontalAlignment = HorizontalAlignment.Left; this.VerticalAlignment = VerticalAlignment.Top; this.Margin = new Thickness(9700, 0, 0, 0); this.Width = 300; this.Height = 70; } catch (Exception e) { } } public string EventCommand = ""; private double OffsetX = 0.0; public void Event() { try { this.MouseLeftButtonDown += (sender, e) => { OffsetX = e.GetPosition(this).X; EventCommand = "Down"; }; MainWindow.UI.MouseLeftButtonUp += (sender, e) => { EventCommand = ""; }; MainWindow.UI.MouseMove += (sender, e) => { if (Mouse.LeftButton == MouseButtonState.Pressed) { if(EventCommand == "Down") { double X = e.GetPosition(RightEffectRow.UI).X; X = X - OffsetX; this.Margin = new Thickness(X, 0, 0, 0); } } }; } catch (Exception e) { } } public void Refresh() { try { } catch (Exception e) { } } } }
- MainWindow.cs | Drag Object To Scroll In WPF C# | Amit Padhiyar | Saatody
- MyRowControl.cs | Drag Object To Scroll In WPF C# | Amit Padhiyar | Saatody
- MyRowTest.cs | Drag Object To Scroll In WPF C# | Amit Padhiyar | Saatody
- MyColor.cs | Drag Object To Scroll In WPF C# | Amit Padhiyar | Saatody
- RightEffectControl.cs | Drag Object To Scroll In WPF C# | Amit Padhiyar | Saatody
- RightEffectRowContainer.cs | Drag Object To Scroll In WPF C# | Amit Padhiyar | Saatody
- RightEffectRow.cs | Drag Object To Scroll In WPF C# | Amit Padhiyar | Saatody
- RightEffect.cs | Drag Object To Scroll In WPF C# | Amit Padhiyar | Saatody
Comments
Post a Comment