[英]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.