I have a popup and I want to make it movable. I have almost got it, but it move in a funky way sometimes (the popup will move but the mouse pointer is not over the popup).
XAML:
<Popup Name="Part_Popup" IsOpen="{Binding ElementName=PART_TogglePlayList, Path=IsChecked}" StaysOpen="True"><StackPanel Orientation="Vertical" ><Rectangle x:Name="theRect" Height="15" Fill="Gray" ></Rectangle><ItemsControl x:Name="Part_PlayList" ItemsSource="{Binding songList}" Background="Wheat" HorizontalContentAlignment="Left" HorizontalAlignment="Stretch" ToolTip="Click to see playing song list" ItemTemplate="{Binding SongListDisplayDataTemplate}" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto"></ItemsControl></StackPanel></Popup>
Here are the three methods used in code behind:
#Region "Popup movement" Private Sub theThumbMouseLeftBUttonDown(sender As Object, e As MouseButtonEventArgs) mouseIsDown = True Dim pop As Rectangle = CType(sender, Rectangle) oldMousePosition = pop.PointToScreen(e.GetPosition(pop)) pop.CaptureMouse() End Sub Private Sub theThumbMouseMove(sender As Object, e As MouseEventArgs) If Not mouseIsDown Then Return End If Dim pop As Rectangle = CType(sender, Rectangle) 'Dim pop As Popup = thePopup Dim newMousePosition = pop.PointToScreen(e.GetPosition(pop)) Dim offset = newMousePosition - oldMousePosition oldMousePosition = newMousePosition pop.Tag.HorizontalOffset += offset.X pop.Tag.VerticalOffset += offset.Y End Sub Private Sub theThumbMouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs) Dim pop As Rectangle = CType(sender, Rectangle) mouseIsDown = False pop.ReleaseMouseCapture() End Sub #End Region
Anyone see my problem
Lloyd Sheen