【发布时间】:2017-06-19 21:52:17
【问题描述】:
在 VS2017 中使用 Xamarin
在我的app.xaml 中,我有一个 MergedDictionary,它引用了一个包含我的 DataTemplate 的 xaml。内容页面无法识别它。如果我将 DataTemplate 移到 app.xaml 中,它可以正常工作。
如何让<ResourceDictionary.MergedDictionaries> 识别CellTemplates.xaml 中定义的StaticResource?
我的 App.xaml:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/CellTemplates.xaml"/>
</ResourceDictionary.MergedDictionaries>
....
我的 CellTemplates.xaml:
<ResourceDictionary
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="CustomerTemplate">
<ViewCell Height="100">
<StackLayout VerticalOptions="FillAndExpand">
....
我的内容页面:
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Muffin"
x:Class="Muffin.MainPage">
<ScrollView>
<ListView ItemsSource="{Binding Customers}"
HasUnevenRows="True"
ItemTemplate="{StaticResource CustomerTemplate}">
</ListView>
....
【问题讨论】:
标签: c# xaml xamarin xamarin.forms