引用我有一个资源字典 - 样式\ StyleDic1,这有一个弹出按钮作为访问资源声明中资源字典中的App.xaml
我把它在我的App.xaml文件,像这样它的资源之一:
<Application
...
...>
<Application.Resources>
...
<ResourceDictionary Source="Styles\StyleDictionary1.xaml" x:Key="StyleDic1"/>
</Application.Resources>
</Application>
我有AppBarButton另一个文件TimeTC.xaml,我想使用弹出的资源就可以了,所以它试图这样
<AppBarButton Icon="Edit" Label="Edit" ... Flyout="{StaticResource ResourceKey=EditFlyout}"/>
但它不工作。我究竟做错了什么?
UPDATE
这里有App.xaml中
<Application
x:Class="SabinusUWP.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SabinusUWP"
RequestedTheme="Light">
<Application.Resources>
<x:Int32 x:Key="TimeFormat">24</x:Int32>
<Color x:Key="grayish">#99CBCBCB</Color>
<Color x:Key="deepgray">#99AAAAAA</Color>
<Color x:Key="black">#FF000000</Color>
<Color x:Key="sleepblack">#FF414141</Color>
<Color x:Key="bluegray">#FFE3F3F2</Color>
<Color x:Key="transparent">#00E3F3F2</Color>
<Color x:Key="green">#CC2B9B2B</Color>
<Color x:Key="hoverGreen">#CC3BC53B</Color>
<SolidColorBrush x:Key="AppBarBtnFBrush" Color="{StaticResource black}"/>
<SolidColorBrush x:Key="AppBarBBrush" Color="{StaticResource grayish}"/>
<SolidColorBrush x:Key="FolderPressedBrush" Color="{StaticResource deepgray}"/>
<SolidColorBrush x:Key="GridBBrush" Color="{StaticResource transparent}"/>
<SolidColorBrush x:Key="TimeTHeadBtn" Color="{StaticResource transparent}"/>
<SolidColorBrush x:Key="TimeTBodyBtn" Color="{StaticResource green}"/>
<SolidColorBrush x:Key="TimeTBodyHoverBtn" Color="{StaticResource hoverGreen}"/>
<SolidColorBrush x:Name="TimeTBodySleepBtn" x:Key="TimeTBodySleepBtn" Color="{StaticResource sleepblack}"/>
<ResourceDictionary Source="Styles\StyleDictionary1.xaml" x:Key="StyleDic1"/>
</Application.Resources>
的全部内容,这里是StyleDictionary1.xaml
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SabinusUWP.Styles">
<!--Bottom Appbar EditFlyout -->
<Flyout x:Name="EditFlyout" x:Key="EditFlyout"
Placement="Bottom">
<Grid Background="White"
Height="150"
Width="100"
CanDrag="True">
<StackPanel Background="White"
x:Name="panel"
Orientation="Vertical"
Height="150"
Width="100">
<Button Content="12 hour"
Click="_12hour"
Height="50"
Width="100"
Background="{StaticResource AppBarBBrush}" />
<Button Content="24 hour"
Click="_24hour"
Height="50"
Width="100"
Background="{StaticResource AppBarBBrush}" />
</StackPanel>
</Grid>
</Flyout>
</ResourceDictionary>
很抱歉,如果我没有正确地传递信息,第二文件(TimeTC.xaml)不是资源字典,它是一个页面。 –
您可以发布App.xaml.cs文件中的元素的* full *内容以及Styles \ StyleDic1.xaml的内容吗? –
mm8