I\'m having a hard time binding a simple static string property to a TextBox.
Here\'s the class with the static property:
These answers are all good if you want to follow good conventions but the OP wanted something simple, which is what I wanted too instead of dealing with GUI design patterns. If all you want to do is have a string in a basic GUI app you can update ad-hoc without anything fancy, you can just access it directly in your C# source.
Let's say you've got a really basic WPF app MainWindow XAML like this,
That will look something like this:
In your MainWindow XAML's source, you could have something like this where all we're doing in changing the value directly via textBlock.Text
's get
/set
functionality:
using System.Windows;
namespace MyWPFApp
{
public partial class MainWindow : Window
{
public MainWindow() { InitializeComponent(); }
private void Button_Click_Poke_Kilroy(object sender, RoutedEventArgs e)
{
textBlock.Text = " \\|||/\r\n" +
" (o o) \r\n" +
"----ooO- (_) -Ooo----";
}
}
}
Then when you trigger that click event by clicking the button, voila! Kilroy appears :)