[英]Why Frame does not find local resource when it's placed inside a ViewBox?
我試圖在< ViewBox />中使用< Frame />控件。 框架控制源是位於名為Pages的文件夾中的頁面。
在頁面中只有一個元素。 由XAML矢量圖像填充的Rectangle 。
為什么這不顯示任何內容?
<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>
如果您在Page
中設置Rectangle
的Width
/ Height
或至少MinWidth
/ MinHeight
,則它應該可以工作:
<Rectangle Fill="{StaticResource intro2}" MinWidth="1" MinHeight="1" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.