WPF Rightbutton problem

T

tshad

I have a WPF page that creates a window with a crazy shape and allows me to
move the window around.

To close the window I right-click insided the window and it closes the
window (as it should).

But it also brings up a menu like the one you get when on the desktop which
stays there until you choose something (you can't escape to get rid of it).
Why am I getting it this menu and how do I stop this behavior.

My xml is:

<Window x:Class="SeeThru.CrazyWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300"
WindowStyle="None" AllowsTransparency="True"
Background="{x:Null}"
<Grid MouseRightButtonDown="WindowClicked"
MouseLeftButtonDown="DragWindow">
<Viewbox Stretch="Uniform">
<Path Fill="#80D0E0FF" Stroke="Red" StrokeThickness="3"
HorizontalAlignment="Center" VerticalAlignment="Center"
Data="M79,3L65,82 17,91 50,138 96,157 104,192 175,154 190,167
218,78 156,76 157,9 111,39z"/>
</Viewbox>
<TextBlock Text="{Binding RelativeSource={RelativeSource
Mode=FindAncestor, AncestorType={x:Type Window}}, Path=Title}"
FontSize="18" Background="Transparent"
HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20"
MouseLeftButtonDown="DragWindow" FontFamily="Impact"
Foreground="#C030A060"/>
<TextBlock Text="Right Click Anywhere to Close" Background="Black"
Width="200" Foreground="White"
VerticalAlignment="Center" HorizontalAlignment="Center"
FontSize="14" TextWrapping="Wrap" />
</Grid>
</Window>

My .xaml.cs file is:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SeeThru
{
/// <summary>
/// Interaction logic for Page1.xaml
/// </summary>
public partial class CrazyWindow : Window
{
public CrazyWindow()
{
InitializeComponent();
}
public void DragWindow(object sender, MouseButtonEventArgs args)
{
DragMove();
}

public void WindowClicked(object sender, MouseButtonEventArgs args)
{
Close();
}

}
}

Not sure if this is the correct newsgroup - can't find a WPF group.

Thanks,

Tom
 
B

behdad

Hey Tom,

I just tried your code and it works fine without the menu.

Best,
Behdad Baniani
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

WPF forms 2
WPF DockPanel positioning 6
Use an ellipse shape as a window. 0
Silverlight grid col question 0
xml name spaces 1
Media in my aspx 2
Silverlight 4 combobox 11
Silverlight 4 combobox 2

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top