MainWindow.xaml.csの全コード
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Reflection;
namespace Bindings
{
public partial class MainWindow : Window
{
TextBlock textblock0 =new TextBlock();
public MainWindow()
{
InitializeComponent();
}
private void textbox1_TextChanged(object sender, TextChangedEventArgs e)
{
textblock0.Text = textbox1.Text;
}
private void slider1_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
{
textblock0.FontSize = slider1.Value;
}
private void textbox2_TextChanged(object sender, TextChangedEventArgs e)
{
PropertyInfo pinfo = typeof(Colors).GetProperty(textbox2.Text);
Color c;
if (pinfo == null)
{
c = Colors.Red;
}
else
{
c =(Color) pinfo.GetValue(null, null);
}
textblock0.Foreground = new SolidColorBrush(c);
}
private void textblock1_Loaded(object sender, RoutedEventArgs e)
{
textblock0 = textblock1;
}
}
}