Link to home
Start Free TrialLog in
Avatar of TeDeSm
TeDeSm

asked on

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

Avatar of vb_student
vb_student
Flag of United States of America image

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.
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
Avatar of TeDeSm
TeDeSm

ASKER

HI,
I'm using a mouse. Regarding the code I'll make some changes and check it out.
Terry
ASKER CERTIFIED SOLUTION
Avatar of mikebirt
mikebirt
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TeDeSm

ASKER

Event handler in xaml and vb. Removed the xaml event and all works as expected. Thanks.