简体   繁体   English

Windows Community Toolkit从回购中导出/回传MasterDetailsView

[英]Windows Community Toolkit export/backport MasterDetailsView from repo

v5.0.0 of the Windows Community Toolkit dropped support for the Creators Update (15063). Windows Community Toolkit的 v5.0.0放弃了对Creators Update(15063)的支持。 Now I want to manually backport the MasterDetailsView XAML Control . 现在,我想手动向后移植MasterDetailsView XAML控件

I've already included the following files from the Windows Community Toolkit v5.0.0 MasterDetailsView XAML Control source code in my project: 我已经在项目中包含Windows Community Toolkit v5.0.0 MasterDetailsView XAML控件源代码中的以下文件:

If I now create one with the following XAML code: 如果现在使用以下XAML代码创建一个:

xmlns:masterdetailsview1="using:ProjectName.Toolkit.MasterDetailsView"
<masterdetailsview1:MasterDetailsView x:Name="chats_mdv"
                                      Grid.Row="1"
                                      Background="Transparent"
                                      DetailsTemplate="{StaticResource DetailsTemplate}"
                                      ItemTemplate="{StaticResource MasterTemplate}"
                                      ItemsSource="{x:Bind ViewModel.CHATS_ACV}"
                                      MasterPaneBackground="{StaticResource AppBackgroundAcrylicElementBrush}"
                                      NoSelectionContentTemplate="{StaticResource NoSelectionTemplate}"
                                      SelectedItem="{x:Bind ViewModel.SelectedItem, Mode=TwoWay}"/>

The result of the code above is a MasterDetailsView XAML Control without any behavior. 上面的代码结果是一个MasterDetailsView XAML控件,没有任何行为。 I can't interact with it. 我无法与之互动。 It's stuck in the master pane only mode. 它停留在仅主窗格模式下。 It does not react if I click on any master item to view it. 如果我单击任何主项目来查看它,它不会反应。

Which files do I have to include in my project for this to work? 我必须在项目中包括哪些文件才能正常工作?

The result of the code above is a MasterDetailsView XAML Control without any behavior. 上面的代码结果是一个MasterDetailsView XAML控件,没有任何行为。 I can't interact with it. 我无法与之互动。 It's stuck in the master pane only mode. 它停留在仅主窗格模式下。 It does not react if I click on any master item to view it. 如果我单击任何主项目来查看它,它不会反应。

I followed your steps to make a code sample to test. 我按照您的步骤制作了代码示例进行测试。 I can reproduce your issue. 我可以重现您的问题。 The problem was that it cannot find the MasterDetalsView.xaml resource file when the OnApplyTemplate() method get called. 问题在于,当OnApplyTemplate()方法时,它找不到MasterDetalsView.xaml资源文件。

To solve this issue, open your project's App.xaml and add the following resource in it. 要解决此问题,请打开项目的App.xaml并在其中添加以下资源。

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/MasterDetailsView/MasterDetailsView.xaml"></ResourceDictionary>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

My project's directory structure like the following: 我项目的目录结构如下:

在此处输入图片说明

You need to change the source by your own project's directory structure. 您需要通过自己的项目的目录结构来更改源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM