wpf mouse left button or button click events are not fire on text box
Hai,
this is koti all know about me i face one problem with text box in wpf when i click on the text box with mouse , mouse click event is not fired plz see... teh code as follow in net i find one solution that is
in load event of the page
textbox1.AddHandler(MouseLeftButtonDown, System.Windows.Input.MouseButtonEventHandler(this.mouseLeftDown),true); but it display the error what is the problem here is xaml
xaml file:-
<Page x:Class="WpfApplication1.button"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="button"
>
<Grid>
<StackPanel>
<TextBox Name="textbox1" MouseLeftButtonDown="textbox1_MouseLeftButtonDown" MouseDown="textbox1_MouseDown" >TextBox>
StackPanel>
Grid>
Page>
c# code:-
private void textbox1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("");
}
private void textbox1_MouseDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("md");
}
Koteswararao MallisettiPosted Jul 15, 2010, 5:56 AM
Praveen KumarPosted Jul 15, 2010, 2:05 AM
In XAML:
<Window x:Class="WpfApplication2.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>
<StackPanel>
<TextBox Name="textbox1" PreviewMouseLeftButtonDown="textbox1_MouseLeftButtonDown" PreviewMouseDown="textbox1_MouseDown">TextBox>
StackPanel>
Grid>
Window>
C# Code will be same.