[コントロール間の連携]をダウンロードする。
<Window x:Class="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">
<Grid x:Name="LayoutRoot" Background="LightCyan">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBox x:Name="textbox1" Margin="5"
Text="スライダーでフォント サイズを変更できます。" />
<Slider Grid.Row="1" x:Name="slider1" Margin="5"
Minimum="10" Maximum="60" Value="16" />
<TextBox Grid.Row="2" x:Name="textbox2" Margin="5" Text="Green" />
<TextBlock Grid.Row="3" Name="textblock1" Text="TextBlock"
Foreground="{Binding ElementName=textBox2, Path=Text}" />
</Grid>
</Window>
Imports System.Reflection
Class MainWindow
Dim textblock0 As New TextBlock
Private Sub textbox1_TextChanged(sender As System.Object, e As System.Windows.Controls.TextChangedEventArgs) Handles textbox1.TextChanged
textblock0.Text = textbox1.Text
End Sub
Private Sub slider1_ValueChanged(sender As System.Object, e As System.Windows.RoutedPropertyChangedEventArgs(Of System.Double)) Handles slider1.ValueChanged
textblock0.FontSize = slider1.Value
End Sub
Private Sub textbox2_TextChanged(sender As System.Object, e As System.Windows.Controls.TextChangedEventArgs) Handles textbox2.TextChanged
Dim pinfo As PropertyInfo = GetType(Colors).GetProperty(textbox2.Text)
Dim c As Color
If pinfo Is Nothing Then c = Colors.Red Else c = pinfo.GetValue(Nothing, Nothing)
textblock0.Foreground = New SolidColorBrush(c)
End Sub
Private Sub textblock1_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles textblock1.Loaded
textblock0 = textblock1
End Sub
End Class