为什么 Frame 放在 ViewBox 里面找不到本地资源?
Why Frame does not find local resource when it's placed inside a ViewBox?
我尝试在 <ViewBox/> 中使用 <Frame/> 控件。
Frame Control 的来源是位于名为 Pages 的文件夹中的页面。
在页面中只有一个元素。用 XAML 矢量图像填充的 矩形 。
为什么不显示任何东西?
<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 是一个大文件。 i post 第一个和最后一个标签:
<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>
如果您设置 Width
/Height
,或者 Page
中 Rectangle
的至少 MinWidth
/MinHeight
,它应该可以工作]:
<Rectangle Fill="{StaticResource intro2}" MinWidth="1" MinHeight="1" />
我尝试在 <ViewBox/> 中使用 <Frame/> 控件。
Frame Control 的来源是位于名为 Pages 的文件夹中的页面。
在页面中只有一个元素。用 XAML 矢量图像填充的 矩形 。
为什么不显示任何东西?
<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 是一个大文件。 i post 第一个和最后一个标签:
<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>
如果您设置 Width
/Height
,或者 Page
中 Rectangle
的至少 MinWidth
/MinHeight
,它应该可以工作]:
<Rectangle Fill="{StaticResource intro2}" MinWidth="1" MinHeight="1" />