Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How can I separate my DataTemplates?

$
0
0

Hello,
I would like my DataTemplates in seperate XAML-Files. Now I have added for every DataTemplate a seperate XAML-File.

One example for a XAML file to seperate the DataTemplates:

<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="A.B.C.D">
        <Application.Resources>
                <ResourceDictionary>
                        <DataTemplate x:Key="aItem">
                                <StackLayout BackgroundColor="Red">
                                        <Label Text="Test" />
                                </StackLayout>
                        </DataTemplate>
                </ResourceDictionary>
        </Application.Resources>
</Application>

In the other file with the ListView I have:
<ListView ItemTemplate={StaticResource aItem} ..... ></ListView>

The problem is, I get every time the error "StaticResource not found for key aItem". How can I solve this with Xamarin? - Is there something like "MergedDictionaries" in Xamarin?

Thanks.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>