WPF Button_click event fires twice

I have one button on a form for which the onclick events fires twice. How do I fix this please?
XAML
<Window x:Class="WindowPurchaseChaser"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Purchase Chaser" Height="360" Width="444" Name="WindowPurchaseChaser">
    <Grid>
		<Label Height="28" Margin="64,13,0,0" Name="lblDateStart" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120" HorizontalContentAlignment="Center">Start Date</Label>
		<Label Height="28" Margin="0,13,55,0" Name="lblDateEnd" VerticalAlignment="Top" HorizontalAlignment="Right" Width="120" HorizontalContentAlignment="Center">End Date</Label>
		<TextBox Height="23" Margin="64,52,0,0" Name="txtbDateStart" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120" IsReadOnly="True"/>
		<TextBox Height="23" HorizontalAlignment="Right" Margin="0,52,55,0" Name="txtbDateEnd" VerticalAlignment="Top" Width="120" />
		<Button Click="btnStart_Click" Margin="178,89,169,0" Name="btnStart" Height="22" VerticalAlignment="Top">Start</Button>
		<TextBox Margin="34,118,37,56" Name="txtProgress" BorderBrush="AliceBlue" />
	</Grid>
</Window>

VB
Private Sub btnStart_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnStart.Click

Open in new window

TeDeSmAsked:
Who is Participating?
 
mikebirtConnect With a Mentor Commented:
Hi,

I'd imagine if you remove either the xaml click hander Click="btnStart_Click" or the VB 'Handles...' you'll find the handler will only be invoked once.

good luck, let us know how you get on

HTH

Mike
0
 
vb_studentCommented:
does this happen on a laptop touchpad or with a normal mouse? i have the same problom on one of my apps. and it was a rare problem. also check the options on the buttons click mode. i belive the default is relesed but that may help. hope this is of use to you.
0
 
mikebirtCommented:
Hi,

could this be because you're assigning the click handler in Xaml and again in code by adding the 'Handles btnStart.Click' at the end of your handler declaration?

HTH

Mike
0
 
TeDeSmAuthor Commented:
HI,
I'm using a mouse. Regarding the code I'll make some changes and check it out.
Terry
0
 
TeDeSmAuthor Commented:
Event handler in xaml and vb. Removed the xaml event and all works as expected. Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.