WPF XBAP项目疯狂

时间:2011-07-19 00:27:46

标签: c# wpf

这是我从书中复制的一个例子。但它疯了。它应该在IE中打开一个页面并做一些事情。但它一个接一个地打开页面,永不停止。我需要关闭整个IE才能将其关闭。这就是我的预期。

我的代码基本上是两个文件,我只更改了一个:Page1.xaml

<Page   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="FontViewerXBAP.Page1"
        WindowTitle="Font Viewer" 
        Height="480" 
        Width="600">
    <DockPanel Margin="8">
        <Border DockPanel.Dock="Top"
                CornerRadius="6"
                BorderThickness="1"
                BorderBrush="Gray"
                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"/>
        <TextBox x:Name="SampleText"
                 DockPanel.Dock="Bottom"
                 MinLines="4"
                 Margin="8 0"
                 TextWrapping="Wrap">
            <TextBox.ToolTip>
                <TextBlock>
                    <Italic Foreground="Red">Instructions: </Italic>
                    Change preview.
                </TextBlock>
            </TextBox.ToolTip>
            The quick brown fox jumps over the lazy dog.
        </TextBox>
        <StackPanel Margin="8 0 8 8">
            <TextBlock Text="{Binding ElementName=SampleText,Path=Text}"
                               FontFamily="{Binding ElementName=FontList,Path=SelectedItem}"
                               FontSize="10"
                               TextWrapping="Wrap"
                               Margin="0 0 0 4"/>
            <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"/>
            <TextBlock Text="{Binding ElementName=SampleText, Path=Text}"
                       FontFamily="{Binding ElementName=FontList, Path=SelectedItem}"
                       FontSize="32"
                       TextWrapping="Wrap"/>
        </StackPanel>
    </DockPanel>
</Page>

和Page1.xaml.cs是自动生成的文件,我没有改变任何文件。

    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace FontViewerXBAP {
    /// <summary>
    /// Interaction logic for Page1.xaml
    /// </summary>
    public partial class Page1 : Page {
        public Page1()
        {
            InitializeComponent();
        }
    }
}

我在书中检查了很多次代码。非常困惑。希望任何人都可以看看,给我一个指南。

0 个答案:

没有答案