- Joined
- May 28, 2007
- Messages
- 1,023
- Reaction score
- 165
I've been following a rather nice ebook, and I'm a bit stuck on something.
I'm currently making the generic WPF application with a label, a text box, and a button.
When you click the button, it'll say Hello (Name you entered in the text box).
My Window1.Xaml.CS:
I double clicked my OK button in my WPF app to add in the ok_click method, and the ebook told me to add the:
But in the ebook, the snippet that contains that has void ok_Click, not private void.
My Window1.xaml:
I'm currently making the generic WPF application with a label, a text box, and a button.
When you click the button, it'll say Hello (Name you entered in the text box).
My Window1.Xaml.CS:
Code:
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 WPFHello
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void ok_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show(“Hello “ + userName.Text);
}
}
}
Code:
MessageBox.Show(“Hello “ + userName.Text);
But in the ebook, the snippet that contains that has void ok_Click, not private void.
My Window1.xaml:
Code:
<Window x:Class="WPFHello.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Hello" Height="140" Width="300">
<Grid>
<Label Height="28" Margin="12,12,120,0" Name="label1" VerticalAlignment="Top" FontSize="12">Please enter your name.</Label>
<TextBox Height="23" Margin="21,36,137,0" Name="userName" VerticalAlignment="Top" TextChanged="userName_TextChanged" />
<Button Height="23" HorizontalAlignment="Right" Margin="0,36,25,0" Name="ok" VerticalAlignment="Top" Width="75" Click="ok_Click">OK</Button>
</Grid>
</Window>