0

我玩弄了这段代码,改变了一些对齐问题。现在与字体的绑定失败了。为什么。需要帮助谢谢。

<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>
4

1 回答 1

1

你不小心变成<ListBox x:Name="Fontlist"<ListBox x:Name="FontList".

于 2012-04-22T00:52:35.473 回答