2017-07-03 72 views
1

我試圖用內< 視框/> 源幀控制的< 框架 />控件是在名爲Pages文件夾中打下了頁面。 而在頁面中只有一個元素。 A 矩形充滿了XAML矢量圖像。爲什麼Frame放入ViewBox時找不到本地資源?

爲什麼這不顯示任何東西?

<Window xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared" 
    x:Class="SearChForComp.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> 
    <Viewbox VerticalAlignment="Center" HorizontalAlignment="Center" > 
     <Frame Source="Pages/mainPage.xaml" NavigationUIVisibility="Hidden" /> 
    </Viewbox> 

</Grid> 

這我的頁面(MainPage.xaml中):

<Page x:Class="SearChForComp.Pages.mainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    mc:Ignorable="d" 

Title="mainPage"> 

<Grid> 
    <Rectangle Fill="{StaticResource intro2}" /> 
</Grid> 

我定義我的資源中的App.xaml像這樣:

<Application x:Class="SearChForComp.App" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     StartupUri="MainWindow.xaml"> 
<Application.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="VectorGrahics/intro2.xaml" /> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Application.Resources> 

而Intro2.xaml是一個大文件。我發表的第一和最後一個標籤:

<ResourceDictionary 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
    <DrawingBrush x:Key="intro2" Stretch="Uniform"> 
     <... \> 
    </DrawingBrush> 
</ResourceDictionary> 
+0

你沒看到網頁或你的問題是什麼? – mm8

+1

還有一件事,Frame可以很好地利用標籤。 –

+0

請發佈您網頁的標記。 – mm8

回答

2

如果你設置了Width/Height,或在PageRectangle的ATLEAST MinWidth/MinHeight它應該工作:

<Rectangle Fill="{StaticResource intro2}" MinWidth="1" MinHeight="1" /> 
+0

謝謝:)爲什麼呢? –

+1

ViewBox無法縮放沒有尺寸的任何東西。 – mm8