您可以将资源添加到窗口的根元素,而不是直接将资源添加到窗口本身:
stackPanelRoot.Resources.Add(...);
XAML:
<Window
x:Class="Greek_Television.MainWindow"
...>
<StackPanel x:Name="stackPanelRoot">
当然你也可以直接在XAML标记中将资源添加到根元素:
<StackPanel>
<StackPanel.Resources>
<GridView x:Key="...">