2017-07-03 70 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