简体   繁体   中英

Windows Community Toolkit export/backport MasterDetailsView from repo

v5.0.0 of the Windows Community Toolkit dropped support for the Creators Update (15063). Now I want to manually backport the MasterDetailsView XAML Control .

I've already included the following files from the Windows Community Toolkit v5.0.0 MasterDetailsView XAML Control source code in my project:

If I now create one with the following XAML code:

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. 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. 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.

To solve this issue, open your project's App.xaml and add the following resource in it.

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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