Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3612474
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:00:14+00:00 2026-05-18T22:00:14+00:00

Howdy, I would like to generate in my application several PivotItems in a pivotelement.

  • 0

Howdy,
I would like to generate in my application several PivotItems in a pivotelement. The generation is proceeding fine, however I don’t know how I can apply a template to those Pivot Elements.

I thought I would need to use:

pivotItem.ContentTemplate = (DataTemplate)Ressources[“KantinenUebersicht”];

But that is only producing an empty page.

My code in the ressource file looks the following:

inserted my whole ressources File

<.ResourceDictionary
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;>

<DataTemplate x:Key="KantinenTemplate">
    <StackPanel VerticalAlignment="Top">
            <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding name}" FontSize="{StaticResource PhoneFontSizeLarge}" Margin="8,0,0,0" VerticalAlignment="Top"/>
            <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding entfernung}" Margin="24,0,0,0" FontSize="{StaticResource PhoneFontSizeSmall}" VerticalAlignment="Bottom"/>
    </StackPanel>
</DataTemplate>

<DataTemplate x:Key="KantinenUebersicht">
        <Grid>
            <TextBlock x:Name="KantinenName" FontSize="{StaticResource PhoneFontSizeExtraLarge}" Text="" RenderTransformOrigin="0.566,0.407" Margin="0,0,8,0" Height="55" VerticalAlignment="Top">
                        <TextBlock.Foreground>
                            <SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
                        </TextBlock.Foreground>
            </TextBlock>
            <TextBlock x:Name="sdfsdf" HorizontalAlignment="Left" Height="40" Margin="8,59,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="196"/>
            <TextBlock x:Name="lblGeoefsdfsdffnet" Height="40" Margin="208,59,8,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/>
        </Grid>
    </DataTemplate></ResourceDictionary.>

Had to insert . in the first tags…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:00:15+00:00Added an answer on May 18, 2026 at 10:00 pm

    What you’re trying to do is correct.

    In your question you have an extra “S” in “Resources” which could be the issue.

    If I take the code from your question, I can add it to the page:

    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Key="KantinenUebersicht">
            <Grid>
                <TextBlock x:Name="KantinenName" FontSize="{StaticResource PhoneFontSizeExtraLarge}" Text="" RenderTransformOrigin="0.566,0.407" Margin="0,0,8,0" Height="55" VerticalAlignment="Top">
                     <TextBlock.Foreground>
                      <SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
                     </TextBlock.Foreground>
                </TextBlock>
                <TextBlock x:Name="lblEntfernung" HorizontalAlignment="Left" Height="40" Margin="8,59,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="196"/>
                <TextBlock x:Name="lblGeoeffnet" Height="40" Margin="208,59,8,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/>
            </Grid>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>
    

    and then use it when creating a new item:

    var newItem = new PivotItem { Header = "Added" };
    
    newItem.ContentTemplate = (DataTemplate)Resources["KantinenUebersicht"];
    
    MyPivot.Items.Add(newItem);
    

    Works on my machine (emulator).

    Update:
    If you want to add the resource to a separate file you can do so like:

    ResourceDictionary.xaml:

    <ResourceDictionary
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
        <DataTemplate x:Key="KantinenUebersicht">
            <Grid>
                <TextBlock x:Name="KantinenName" FontSize="{StaticResource PhoneFontSizeExtraLarge}" Text="" RenderTransformOrigin="0.566,0.407" Margin="0,0,8,0" Height="55" VerticalAlignment="Top">
                         <TextBlock.Foreground>
                          <SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
                         </TextBlock.Foreground>
                </TextBlock>
                <TextBlock x:Name="lblEntfernung" HorizontalAlignment="Left" Height="40" Margin="8,59,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="196"/>
                <TextBlock x:Name="lblGeoeffnet" Height="40" Margin="208,59,8,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/>
            </Grid>
        </DataTemplate>
    </ResourceDictionary>
    

    Then you must reference this external file in the page which wishes to use this file.

    <phone:PhoneApplicationPage.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="\ResourceDictionary.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </phone:PhoneApplicationPage.Resources>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to slice random letters from a string. Given s="howdy" I would
Howdy, I'm currentyl new to Java and Android but I would like to write
Howdy. It's me again, and It's jQuery again. I have somthing like that: http://misiur.com/small/
Howdy, I do know how to implement a simple bubble-sort for 1dimensional array. But
Howdy, I'm generating a bunch of Textblocks in a StackPanel. I would love to
Howdy, I've got another question regarding phone 7... I want to generate a couple
Howdy, I'd like to create a website with c# and ASP.NET. This Website should
I would like make all text within div.main gray except for all content within
I'm sending like this: Pony.mail :to => 'me@mine.com.au', :from => 'me@mine.com.au', :subject => 'Howdy,
Howdy! I am looking for a way to list all of the image files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.