Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@julesx
Created December 10, 2014 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julesx/5cd67796a7a6ff509751 to your computer and use it in GitHub Desktop.
Save julesx/5cd67796a7a6ff509751 to your computer and use it in GitHub Desktop.
yes
<Window x:Class="WpfApplication1.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">
<StackPanel Orientation="Vertical">
<Label Content="{Binding TestString}" />
<Button Content="Click Me" Click="Button_Click" />
</StackPanel>
</Window>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading;
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;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window, INotifyPropertyChanged
{
public MainWindow()
{
InitializeComponent();
DataContext = this;
}
#region Property Changes
public event PropertyChangedEventHandler PropertyChanged;
private string _testString;
public string TestString
{
get { return _testString; }
set
{
_testString = value;
OnPropertyChanged("TestString");
}
}
public void OnPropertyChanged(string propertyName, object before = null, object after = null)
{
//Perform property validation
var propertyChanged = PropertyChanged;
if (propertyChanged != null)
{
propertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
public void ThreadTest()
{
TestString = DateTime.Now.ToString();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var MyThread = new Thread(new ThreadStart(ThreadTest));
MyThread.Start();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment