2011-04-21 324 views
0

繼.aspx頁面中:Visual Studio XAML網站。 XAML將不會加載

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Vowels.aspx.cs" Inherits="XMLPraktijkOpdrachtJavascript.Vowels" %> 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" > 
    <head> 
     <title>Vowels</title> 
     <script type="text/javascript" src="Javascript/Vowels.js"></script> 
    </head> 
    <body> 
     <object id="VowelsPage" width="100%" height="100%" type="application/x-silverlight">     
      <param name="source" value="Xaml/Vowels.xaml"/>    
     </object>     
    </body> 
</html> 

使用此XAML文件:

http://pastebin.com/1sFX93Bp(這是一個有點長,張貼在這裏)

但我的網頁根本無法加載。它說白色。如果我將第20行的所有內容註釋掉,它都可以工作(即:執行剩餘的代碼)。

有什麼問題,還是有沒有像樣的Xaml調試器?由於Visual Studio不會讓你在xaml文件中放置斷點。

回答

1

可以請你改變這個

TargetType="{x:Type TextBlock}" 

TargetType="TextBlock" 

,你也需要刪除

<Setter Property="Background" Value="#FF3B596E"/> 
<Setter Property="Background" Value="#FF3B5940"/> 

,改變

<Setter Property="FontSize" Value="24px"/> 
<Setter Property="FontSize" Value="14px"/> 
<Setter Property="FontSize" Value="14px"/> 

<Setter Property="FontSize" Value="24"/> 
<Setter Property="FontSize" Value="14"/> 
<Setter Property="FontSize" Value="14"/> 

完整的XAML腳本如下圖所示,

<?xml version="1.0" encoding="UTF-8"?> 
<Grid 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 

    Loaded="OnLoaded"> 

    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="*"/> 
     <ColumnDefinition Width="600"/> 
     <ColumnDefinition Width="*"/> 
    </Grid.ColumnDefinitions> 

    <Grid.Background> 
     <LinearGradientBrush> 
      <GradientStop Color="Red"/> 
      <GradientStop Color="#FF3B596E" Offset="1"/> 
     </LinearGradientBrush> 
    </Grid.Background> 
    <Grid Grid.Column="1" Grid.Row="1"> 
     <Grid.Resources> 
      <Style x:Key="TitleText" 
      TargetType="TextBlock"> 
       <Setter Property="FontFamily" Value="Segoe Black"/> 
       <Setter Property="FontSize" Value="24"/> 
       <Setter Property="Foreground" Value="MidnightBlue"/> 
       <Setter Property="TextAlignment" Value="Center"/> 
       <Setter Property="VerticalAlignment" Value="Center"/> 
      </Style> 
      <Style x:Key="LabelText" 
      TargetType="TextBlock"> 
       <Setter Property="FontFamily" Value="Segoe Black"/> 
       <Setter Property="FontSize" Value="14"/> 
       <Setter Property="Foreground" Value="#FFB3B4C1"/> 
       <Setter Property="TextAlignment" Value="Center"/> 
       <Setter Property="VerticalAlignment" Value="Center"/> 

      </Style> 
      <Style x:Key="ValueText" 
      TargetType="TextBlock"> 
       <Setter Property="FontFamily" Value="Segoe Black"/> 
       <Setter Property="FontSize" Value="14"/> 
       <Setter Property="Foreground" Value="Ivory"/> 
       <Setter Property="TextAlignment" Value="Center"/> 
       <Setter Property="VerticalAlignment" Value="Center"/> 

      </Style> 
     </Grid.Resources> 
     <Grid.Background> 
      <LinearGradientBrush> 
       <GradientStop Color="#93C5E8"/> 
       <GradientStop Color="#3B596E" Offset="1"/> 
      </LinearGradientBrush> 
     </Grid.Background> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="3*"/> 
      <ColumnDefinition Width="1*"/> 
      <ColumnDefinition Width="3*"/> 
      <ColumnDefinition Width="1*"/> 
      <ColumnDefinition Width="3*"/> 
      <ColumnDefinition Width="1*"/> 
     </Grid.ColumnDefinitions> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="70"/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
     </Grid.RowDefinitions> 
     <TextBlock Grid.ColumnSpan="6" Style="{StaticResource TitleText}"> 
        Vowel Details 
     </TextBlock> 
     <TextBlock Grid.Column="0" Grid.Row="1" Style="{StaticResource LabelText}">Strings with frequency &gt; 50</TextBlock> 
     <Button Height="23" HorizontalAlignment="Stretch" VerticalAlignment="Center" 
      Content="Sort" 
      Grid.Column="0" 
      Grid.Row="4" 
      Name="btnSort50"/> 
     <TextBlock Grid.Column="1" Grid.Row="1" Style="{StaticResource ValueText}">128</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="1" Style="{StaticResource LabelText}">Starting with a Vowel</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="1" Style="{StaticResource ValueText}">51</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="2" Style="{StaticResource LabelText}">a</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="2" Style="{StaticResource ValueText}">12</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="3" Style="{StaticResource LabelText}">e</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="3" Style="{StaticResource ValueText}">22</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="4" Style="{StaticResource LabelText}">i</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="4" Style="{StaticResource ValueText}">7</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="5" Style="{StaticResource LabelText}">o</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="5" Style="{StaticResource ValueText}">7</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="6" Style="{StaticResource LabelText}">u</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="6" Style="{StaticResource ValueText}">3</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="1" Style="{StaticResource LabelText}">Ending with a Vowel</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="1" Style="{StaticResource ValueText}">52</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="2" Style="{StaticResource LabelText}">a</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="2" Style="{StaticResource ValueText}">7</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="3" Style="{StaticResource LabelText}">e</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="3" Style="{StaticResource ValueText}">27</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="4" Style="{StaticResource LabelText}">i</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="4" Style="{StaticResource ValueText}">5</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="5" Style="{StaticResource LabelText}">o</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="5" Style="{StaticResource ValueText}">9</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="6" Style="{StaticResource LabelText}">u</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="6" Style="{StaticResource ValueText}">4</TextBlock> 
     <TextBlock Grid.Column="0" Grid.Row="7" Style="{StaticResource LabelText}">Strings with frequency &gt; 40</TextBlock> 
     <Button Height="23" HorizontalAlignment="Stretch" VerticalAlignment="Center" 
      Content="Sort" 
      Grid.Column="0" 
      Grid.Row="10" 
      Name="btnSort40"/> 
     <TextBlock Grid.Column="1" Grid.Row="7" Style="{StaticResource ValueText}">182</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="7" Style="{StaticResource LabelText}">Starting with a Vowel</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="7" Style="{StaticResource ValueText}">78</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="8" Style="{StaticResource LabelText}">a</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="8" Style="{StaticResource ValueText}">15</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="9" Style="{StaticResource LabelText}">e</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="9" Style="{StaticResource ValueText}">36</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="10" Style="{StaticResource LabelText}">i</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="10" Style="{StaticResource ValueText}">13</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="11" Style="{StaticResource LabelText}">o</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="11" Style="{StaticResource ValueText}">10</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="12" Style="{StaticResource LabelText}">u</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="12" Style="{StaticResource ValueText}">4</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="7" Style="{StaticResource LabelText}">Ending with a Vowel</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="7" Style="{StaticResource ValueText}">75</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="8" Style="{StaticResource LabelText}">a</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="8" Style="{StaticResource ValueText}">14</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="9" Style="{StaticResource LabelText}">e</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="9" Style="{StaticResource ValueText}">38</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="10" Style="{StaticResource LabelText}">i</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="10" Style="{StaticResource ValueText}">8</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="11" Style="{StaticResource LabelText}">o</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="11" Style="{StaticResource ValueText}">10</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="12" Style="{StaticResource LabelText}">u</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="12" Style="{StaticResource ValueText}">5</TextBlock> 
     <TextBlock Grid.Column="0" Grid.Row="13" Style="{StaticResource LabelText}">Strings with frequency &gt; 30</TextBlock> 
     <Button Height="23" HorizontalAlignment="Stretch" VerticalAlignment="Center" 
      Content="Sort" 
      Grid.Column="0" 
      Grid.Row="16" 
      Name="btnSort30"/> 
     <TextBlock Grid.Column="1" Grid.Row="13" Style="{StaticResource ValueText}">247</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="13" Style="{StaticResource LabelText}">Starting with a Vowel</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="13" Style="{StaticResource ValueText}">100</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="14" Style="{StaticResource LabelText}">a</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="14" Style="{StaticResource ValueText}">18</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="15" Style="{StaticResource LabelText}">e</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="15" Style="{StaticResource ValueText}">48</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="16" Style="{StaticResource LabelText}">i</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="16" Style="{StaticResource ValueText}">19</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="17" Style="{StaticResource LabelText}">o</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="17" Style="{StaticResource ValueText}">11</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="18" Style="{StaticResource LabelText}">u</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="18" Style="{StaticResource ValueText}">4</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="13" Style="{StaticResource LabelText}">Ending with a Vowel</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="13" Style="{StaticResource ValueText}">103</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="14" Style="{StaticResource LabelText}">a</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="14" Style="{StaticResource ValueText}">19</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="15" Style="{StaticResource LabelText}">e</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="15" Style="{StaticResource ValueText}">55</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="16" Style="{StaticResource LabelText}">i</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="16" Style="{StaticResource ValueText}">10</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="17" Style="{StaticResource LabelText}">o</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="17" Style="{StaticResource ValueText}">13</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="18" Style="{StaticResource LabelText}">u</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="18" Style="{StaticResource ValueText}">6</TextBlock> 
     <TextBlock Grid.Column="0" Grid.Row="19" Style="{StaticResource LabelText}">Strings with frequency &gt; 20</TextBlock> 
     <Button Height="23" HorizontalAlignment="Stretch" VerticalAlignment="Center" 
      Content="Sort" 
      Grid.Column="0" 
      Grid.Row="22" 
      Name="btnSort20"/> 
     <TextBlock Grid.Column="1" Grid.Row="19" Style="{StaticResource ValueText}">392</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="19" Style="{StaticResource LabelText}">Starting with a Vowel</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="19" Style="{StaticResource ValueText}">170</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="20" Style="{StaticResource LabelText}">a</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="20" Style="{StaticResource ValueText}">34</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="21" Style="{StaticResource LabelText}">e</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="21" Style="{StaticResource ValueText}">77</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="22" Style="{StaticResource LabelText}">i</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="22" Style="{StaticResource ValueText}">29</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="23" Style="{StaticResource LabelText}">o</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="23" Style="{StaticResource ValueText}">21</TextBlock> 
     <TextBlock Grid.Column="2" Grid.Row="24" Style="{StaticResource LabelText}">u</TextBlock> 
     <TextBlock Grid.Column="3" Grid.Row="24" Style="{StaticResource ValueText}">9</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="19" Style="{StaticResource LabelText}">Ending with a Vowel</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="19" Style="{StaticResource ValueText}">161</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="20" Style="{StaticResource LabelText}">a</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="20" Style="{StaticResource ValueText}">27</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="21" Style="{StaticResource LabelText}">e</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="21" Style="{StaticResource ValueText}">81</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="22" Style="{StaticResource LabelText}">i</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="22" Style="{StaticResource ValueText}">24</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="23" Style="{StaticResource LabelText}">o</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="23" Style="{StaticResource ValueText}">20</TextBlock> 
     <TextBlock Grid.Column="4" Grid.Row="24" Style="{StaticResource LabelText}">u</TextBlock> 
     <TextBlock Grid.Column="5" Grid.Row="24" Style="{StaticResource ValueText}">9</TextBlock> 
    </Grid> 
</Grid> 
+0

感謝您的幫助,但不幸的是,不解決它。 頁面保持完全白色,並且我的OnLoad事件不會觸發。 – Matthias 2011-04-26 15:10:11

+0

是否有替代 ? 因爲我需要有這種顏色的背景。 – Matthias 2011-04-26 18:25:20

+0

頁面左下方是否有黃色警告圖標?如果是的話msg有什麼錯誤?您的TextBlock也無法使用背景顏色,因此需要將TextBlock更改爲Label。 – 2011-04-26 23:59:42