我正试图将某些法典提升到一个层次,以便某些风格能够分享看法。 然而,它用类似于以下信息打破了建筑(取决于我是否只是行文或整个资源字典):
Cannot find a Resource with the Name/Key ImageGridView_ItemTemplate Cannot find a Resource with the Name/Key ImageGridView_ItemContainerStyle
So my original code looks something like the following. And it is working as expected, the item template is being applied and it builds, runs, and looks correct.
<UserControl
x:Class="TrackingStation.Views.JobListViewPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:modelsNs="using:ModelsNamespace"
mc:Ignorable="d">
<Grid x:Name="RemoveThisTest">
<Grid Background="{ThemeResource MainBackgroundColourTheme}">
<Grid.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<DataTemplate x:Key="ImageGridView_ItemTemplate" x:DataType="ModelsNs:CheckInEvent">
<!-- The template -->
</DataTemplate>
</ResourceDictionary>
<ResourceDictionary Source="/Resources/CheckoutJobStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Grid.Resources>
<GridView x:Name="WorkItemGridView"
ItemsSource="{x:Bind ViewModel.SelectedResource.WorkItems, Mode=OneWay}"
ItemTemplate="{StaticResource ImageGridView_ItemTemplate}"
ItemContainerStyle="{StaticResource ImageGridView_ItemContainerStyle}"
ItemsPanel="{StaticResource ImageGridView_ItemsPanelTemplate}"
/>
</Grid>
</Grid>
</UserControl>
Initially it was not in a Resource dictionary etc it was just directly in a resource along with the styles, but I moved them out and merged the dictionaries.
如果我把电网资源移至原电网被nes入的Grid,那么它就会继续工作。
然而,如果我向包含用户控制的电网提升一个等级,那么它就与上述错误信息脱节。 这个没有资源的网格就是:
<UserControl
x:Class="TrackingStation.Views.CheckoutFrame"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="using:TrackingStation.Views"
mc:Ignorable="d">
<Grid>
<local:JobListViewPanel Visibility="{x:Bind ViewModel.IsResourceSelected, Mode=OneWay}" ViewModel="{x:Bind ViewModel, Mode=OneWay}" />
<local:JobViewPanel Visibility="{x:Bind ViewModel.ShowSingleEventForm, Mode=OneWay}" ViewModel="{x:Bind ViewModel, Mode=OneWay}" />
</Grid>
</UserControl>
再加上电网资源:
<UserControl
x:Class="TrackingStation.Views.CheckoutFrame"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="using:TrackingStation.Views"
xmlns:modelsNs="using:ModelsNamespace"
mc:Ignorable="d">
<Grid>
<Grid.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<DataTemplate x:Key="ImageGridView_ItemTemplate" x:DataType="modelsNs:CheckInEvent">
<!-- the template -->
</DataTemplate>
</ResourceDictionary>
<ResourceDictionary Source="/Resources/CheckoutJobStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Grid.Resources>
<local:JobListViewPanel Visibility="{x:Bind ViewModel.IsResourceSelected, Mode=OneWay}" ViewModel="{x:Bind ViewModel, Mode=OneWay}" />
<local:JobViewPanel Visibility="{x:Bind ViewModel.ShowSingleEventForm, Mode=OneWay}" ViewModel="{x:Bind ViewModel, Mode=OneWay}" />
</Grid>
</UserControl>
在申请的顶端,我有各种各样的其他风格,包括纽托文风格,但这些风格并不重要,只是通用风格。
我100%肯定我做些事情,因此我无需告诉我。 但是,我的理解是,儿童应当有同样的风格,即应用根基确定的纽州风格在整个方案过程中影响到纽芬兰。
Just for completeness, the styles currently are simply:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Style x:Key="ImageGridView_ItemContainerStyle" TargetType="GridViewItem">
<Setter Property="Background" Value="{ThemeResource SecondaryBackgroundColourTheme}"/>
<Setter Property="Margin" Value="{StaticResource DefaultMargin}"/>
</Style>
<ItemsPanelTemplate x:Key="ImageGridView_ItemsPanelTemplate">
<ItemsWrapGrid Orientation="Horizontal" HorizontalAlignment="Center"/>
</ItemsPanelTemplate>
</ResourceDictionary>