filmov
tv
Move or Drag a Control in WPF (Example)

Показать описание
WPF,C#: Bewegen eines Controls in einem wpf Formular
Aufgabe: ich möchte mit der Maus eine Textbox auf meinem WPF Formular, meiner WPF Anwendung bewegen.
Lösung: man kann ein Control auf einem WPF Fenster bewegen, indem man die 4-Margin-Werte des Controls zur Laufzeit anpasst.
Hierzu muss man zur Laufzeit berechnen, wie groß die Abstände zur oberen Kante, dem linken Rand, dem rechten Rand und zum unteren Rand sind.
Vereinfacht kann man sagen.
Der Obere Rand (TopMargin) ist durch die Mausposition Y gegeben, gegenüber dem Grid gerechnet, minus dem kleinen Abstand des Punktes wo man im Control selbst draufklickt.
Der untere Rand (BottomMargin) ist die aktuelle Windows-Höhe minus dem Fenster Rand und der Höhe des Fenster-Titels und minus dem oberen Rand und der eigentlichen Control-Höhe.
Zur Laufzeit sieht das dann so aus, wobei das gelbe Feld bewegt werden kann mit der Maus
Dann muß man diesen Margin nur noch dem Control während der Maus-Bewegung zuweisen und schon bewegt sich das Control.
Hier ein einfacher Code: (ein paar kleine Fehler oder Ungenauigkeiten sind noch drin, wie die Korrektur des Offset innerhalb des bewegenden Textbox Controls, aber als Grundgerüst zum Programmieren reicht es aus.
Move or Drag a Control in WPF (Example)
NE #72 WPF Drag-And-Drop aka Runtime Moving A Control With Mouse
Never drag your numbers down in with SEQUENCE! #excel #exceltips #learnexcel #microsoftexcel #msexce
How to drag and drop cell in Excel
Move/Drag Controls - Quick Snips #1
Move Meeting Controls: NEW Teams feature - Drag the Presenter toolbar
Work without a mouse !! | #computer #typing #keyboard #asmr #tricks #fasttypingkeyboard
C# Picture box Control | Move and Drag Image With Mouse | Picturebox C#
Master These 5 Elite Handles – Be UNGUARDABLE 👣💥basketballTraining dribblingdrills
Move multiple apps on your iPhone at once! #shorts
COMPUTER MOUSE | Right-click & Drag-and-drop | CLASS 1 | PART 4
Stepover Tutorial ⬇️
F1 Cars Have No Keys 🤯
How to Drag in WWE 2K25 (Xbox, PlayStation, PC)
BGMI PUBG MOBILE 2X SPEED JOYSTICK SETTING #shorts
How To Do Every New Skill Moves In FC 25 #eafc25 #skillmoves #fc25 #skills
😱 Best fire button size in free fire 100% working ⚡ fire button position #freefire #shorts #foryou...
how to fix stick drift #gaming #console #ps5 #ps4 #xbox #stickdrift
how to turn on/off split control in mcpe before 1:20 #trending
New Headshot Trick Free Fire 😱
Sergio Busquets had 0 Pressure. 😍
HOW TO DO TOXIC SKILL MOVES in FC 25(pt.2) #ronaldo #bellingham #fc25 #football #soccer #skills
Hearing noises, like grinding, crunching and squeeling?
How to improve dribbling at home
Комментарии