私はこのコードをいじって、いくつかの配置の問題を変更しました。これで、フォントとのバインドは失敗します。なぜ。助けが必要ですありがとう。
<Window x:Class="FontViewer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Font Viewer" Height="480" Width="600">
<DockPanel Margin="8" LastChildFill="False">
<Border DockPanel.Dock="Top"
CornerRadius="6"
BorderThickness="1"
BorderBrush="Gray"
Background="LightGray"
Padding="8"
Margin="0 0 0 8">
<TextBlock FontSize="14"
TextWrapping="Wrap">
Select a font to view from the list below.
You can change the text by typing in the region at the bottom.
</TextBlock>
</Border>
<ListBox x:Name="FontList"
DockPanel.Dock="Left"
ItemsSource="{x:Static Fonts.SystemFontFamilies}"
Width="160"/>
<StackPanel Margin="8 0 8 8" DockPanel.Dock="Bottom">
<TextBlock Text="{Binding ElementName=SampleText, Path=Text}"
FontFamily="{Binding ElementName=Fontlist, Path=SelectedItem}"
FontSize="10"
TextWrapping="Wrap"
Margin="0 0 0 4"
HorizontalAlignment="right"
VerticalAlignment="Bottom"/>
<TextBlock Text="{Binding ElementName=SampleText, Path=Text}"
FontFamily="{Binding ElementName=Fontlist, Path=SelectedItem}"
FontSize="16"
TextWrapping="Wrap"
Margin="0 0 0 4"/>
<TextBlock Text="{Binding ElementName=SampleText, Path=Text}"
FontFamily="{Binding ElementName=Fontlist, Path=SelectedItem}"
FontSize="24"
TextWrapping="Wrap"
Margin="0 0 0 4"
HorizontalAlignment="right"/>
<TextBlock Text="{Binding ElementName=SampleText, Path=Text}"
FontFamily="{Binding ElementName=Fontlist, Path=SelectedItem}"
FontSize="32"
TextWrapping="Wrap"/>
</StackPanel>
<TextBox x:Name="SampleText"
VerticalAlignment="Top"
MinLines="2"
Margin="8 0 0 0"
TextWrapping="Wrap"
ToolTip="Type here to change the priview text.">
The quick brown fox jumps over the lazy dog.
</TextBox>
</DockPanel>
</Window>