Created
December 10, 2014 16:50
-
-
Save julesx/5cd67796a7a6ff509751 to your computer and use it in GitHub Desktop.
yes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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