将自定义 GridView 添加到 WinUI 3 C# 应用程序(无法使用 Page.Resources 或 Window.Resources)

问题描述 投票:0回答:1
c# xaml gridview resources winui-3
1个回答
0
投票

您可以将资源添加到窗口的根元素,而不是直接将资源添加到窗口本身:

stackPanelRoot.Resources.Add(...);

XAML:

<Window
    x:Class="Greek_Television.MainWindow"
    ...>


    <StackPanel x:Name="stackPanelRoot">

当然你也可以直接在XAML标记中将资源添加到根元素:

<StackPanel>
    <StackPanel.Resources>
         <GridView x:Key="...">
© www.soinside.com 2019 - 2024. All rights reserved.