Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- 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;
- using System.IO;
- namespace DogAdoption_Form
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- const string DISPLAY_NAME = "Name will display here...";
- public MainWindow()
- {
- InitializeComponent();
- //DisplayLstBoxDogNames();
- }
- public void DisplayLstBoxDogNames()
- {
- lstBoxDogNames.Items.Add("Chloe");
- lstBoxDogNames.Items.Add("Daisy");
- lstBoxDogNames.Items.Add("Emmett");
- lstBoxDogNames.Items.Add("Jack");
- lstBoxDogNames.Items.Add("Lucy");
- lstBoxDogNames.Items.Add("Nala");
- lstBoxDogNames.Items.Add("Peach");
- lstBoxDogNames.Items.Add("Rocky");
- lstBoxDogNames.Items.Add("Shiloh");
- lstBoxDogNames.Items.Add("Toby");
- foreach (string dogName in lstBoxDogNames.Items)
- {
- if (txtBoxName.Text == DISPLAY_NAME)
- {
- //txtBoxName.Text.Replace(DISPLAY_NAME, dogName);
- txtBoxName.Text = dogName;
- txtBoxName.Foreground = Brushes.Black;
- }
- else if ((txtBoxName.Text != DISPLAY_NAME) || (txtBoxName.Text == ""))
- {
- //txtBoxName.Text.Replace(txtBoxName.Text, dogName);
- txtBoxName.Text = dogName;
- txtBoxName.Foreground = Brushes.Black;
- }
- }
- }
- private void txtBoxName_GotFocus(object sender, RoutedEventArgs e)
- {
- DisplayLstBoxDogNames();
- }
- private void txtBoxName_LostFocus(object sender, RoutedEventArgs e)
- {
- if (txtBoxName.Text == DISPLAY_NAME)
- {
- txtBoxName.Foreground = Brushes.Gray;
- }
- else if (txtBoxName.Text != DISPLAY_NAME)
- {
- txtBoxName.Foreground = Brushes.Gray;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement