Click here to Skip to main content
15,889,867 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Wpf doesnt recognize my xmlns for User Control Pin
Abhinav S26-Jun-13 18:31
Abhinav S26-Jun-13 18:31 
GeneralRe: Wpf doesnt recognize my xmlns for User Control Pin
tomr127-Jun-13 8:20
tomr127-Jun-13 8:20 
GeneralRe: Wpf doesnt recognize my xmlns for User Control Pin
Meshack Musundi3-Jul-13 1:02
professionalMeshack Musundi3-Jul-13 1:02 
Questionwindowmediasdk for silverlight Pin
brodcasting26-Jun-13 0:24
brodcasting26-Jun-13 0:24 
QuestionDraging Grids in WPF Pin
tomr125-Jun-13 16:06
tomr125-Jun-13 16:06 
AnswerRe: Draging Grids in WPF Pin
sorawit amorn27-Jun-13 11:25
sorawit amorn27-Jun-13 11:25 
GeneralRe: Draging Grids in WPF Pin
tomr11-Jul-13 15:44
tomr11-Jul-13 15:44 
GeneralRe: Draging Grids in WPF Pin
sorawit amorn3-Jul-13 5:32
sorawit amorn3-Jul-13 5:32 
you will have the object to hold your grid references when you click on and the you can define MouseMove event of you canvas to set new position every time the event trigger.

I don't remember VB syntax, but on c#, It will be ...

Code
C#
 Grid mygrid;

 private MouseButtonEvent MouseLeftButtonDown(Object sender, MouseButtonEventArgs e){
    grid = sender as Grid;
    if(grid!= null){
          mygrid = grid;
    }
}

private MouseEventHandler MoveChildObject(Object sender, MouseEventHandler e){
    if(mygrid != null){
        Point p = Mouse.GetPosition(canvas);
        ControlGrid.SetValue(Canvas.TopProperty, p.Y);
        ControlGrid.SetValue(Canvas.LeftProperty, p.X);
    }
 }

private MouseButtonEvent mouseLeave(Object sender, MouseButtonEventArgs e){
     mygrid = null;
}


XMAL
XML
<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Canvas x:Name="ControlCanvas" Background="AliceBlue" MouseOver="MoveChildObject" >
            <Grid x:Name="ControlGrid" Width="100" Height="40" MouseLeftButtonUp="mouseLeave" MouseLeftButtonDown="MouseLeftButtonDown" >
                <Rectangle Fill="Black"/>
            </Grid>
        </Canvas>
        
    </Grid>
</Window>


NOTE :: you do not need to use grid, if you just use it for holding the rectangle. Just use rectangle object
AnswerRe: Draging Grids in WPF Pin
sorawit amorn3-Jul-13 5:33
sorawit amorn3-Jul-13 5:33 
Question[SOLVED] WPF Combobox background color Pin
Saksida Bojan22-Jun-13 7:31
Saksida Bojan22-Jun-13 7:31 
AnswerRe: WPF Combobox background color Pin
Mycroft Holmes22-Jun-13 13:43
professionalMycroft Holmes22-Jun-13 13:43 
GeneralRe: WPF Combobox background color Pin
Saksida Bojan22-Jun-13 20:43
Saksida Bojan22-Jun-13 20:43 
GeneralRe: WPF Combobox background color Pin
Mycroft Holmes22-Jun-13 21:48
professionalMycroft Holmes22-Jun-13 21:48 
GeneralRe: WPF Combobox background color Pin
Saksida Bojan22-Jun-13 23:09
Saksida Bojan22-Jun-13 23:09 
AnswerRe: WPF Combobox background color Pin
Abhinav S22-Jun-13 18:36
Abhinav S22-Jun-13 18:36 
GeneralRe: WPF Combobox background color Pin
Saksida Bojan22-Jun-13 20:46
Saksida Bojan22-Jun-13 20:46 
GeneralRe: WPF Combobox background color Pin
Abhinav S23-Jun-13 17:29
Abhinav S23-Jun-13 17:29 
QuestionCan attached behaviors have knowledge of ViewModels? Pin
sthotakura21-Jun-13 6:29
sthotakura21-Jun-13 6:29 
AnswerRe: Can attached behaviors have knowledge of ViewModels? Pin
Abhinav S22-Jun-13 18:32
Abhinav S22-Jun-13 18:32 
GeneralRe: Can attached behaviors have knowledge of ViewModels? Pin
sthotakura25-Jun-13 3:47
sthotakura25-Jun-13 3:47 
QuestionButton disables when bind command Pin
maxRazar20-Jun-13 18:27
maxRazar20-Jun-13 18:27 
AnswerRe: Button disables when bind command Pin
Pete O'Hanlon20-Jun-13 20:21
mvePete O'Hanlon20-Jun-13 20:21 
QuestionError in Wpf Pin
Nick_Frenk16-Jun-13 21:57
Nick_Frenk16-Jun-13 21:57 
AnswerRe: Error in Wpf Pin
Pete O'Hanlon16-Jun-13 23:20
mvePete O'Hanlon16-Jun-13 23:20 
GeneralRe: Error in Wpf Pin
Nick_Frenk17-Jun-13 0:03
Nick_Frenk17-Jun-13 0:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.