I have a WPF window that is completely transparent with no title bar that contains a few buttons. How can I drag just the controls around?
0
votes
Look at drag and drop and put the controls on a canvas. msdn.microsoft.com/en-us/library/ms742859.aspx And don't use the term form in WFP.
- paparazzo
You want to drag window or just each control separately?
- Sebastian Ðymel
I want to drag all the controls on the window together, but I do not want to drag the window -- only the controls.
- Lunyx
1 Answers
1
votes
Download the DragCanvas.cs from here
its inherited from Canvas
control give it a transparent background, and it'll do the job for you.
You can also add a DragCanvas as child to another DragCanvas and move many controls at the same time
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication2"
Title="MainWindow" Height="350" Width="525">
<Grid>
<local:DragCanvas Background="Green">
<Grid Canvas.Left="48" Canvas.Top="57">
<Image Source="cursor_drag_arrow.png" Margin="233,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="33" Width="29"></Image>
<Button Content="Button" x:Name="btn" HorizontalAlignment="Left" Height="52" Margin="110,77,0,0" VerticalAlignment="Top" Width="124"/>
<Button Content="Button" x:Name="btn_Copy" HorizontalAlignment="Left" Height="52" Margin="10,10,0,0" VerticalAlignment="Top" Width="124"/>
</Grid>
</local:DragCanvas>
</Grid>
</Window>
there is no code behind this just click on the image and drag
and