你好, 我想在我的应用程序中生成几个PivotItems在pivotelement。这代人进行得很好,但我不知道如何将模板应用到这些枢轴元素。如何用数据填充生成的枢轴元素[模板]
我想我会需要使用:
pivotItem.ContentTemplate =(DataTemplate中)Ressources [ “KantinenUebersicht”];
但是这只是产生一个空白页面。
我在的ressource文件中的代码看起来如下:
插入了我的整个ressources文件
< .ResourceDictionary 的xmlns =“http://schemas.microsoft.com/winfx/2006/ XAML /表示” 的xmlns:X = “http://schemas.microsoft.com/winfx/2006/xaml”>
<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.>
不得不插 。在第一个标签...
实际上,第二个资源是在输入框中发生的错误。但是缺少的是'',但是当我将其添加到我的资源文件时,它会返回错误 –
theXs
2010-12-20 15:28:08
@theXs什么是您的“资源文件”?我上面的代码示例来自MainPage.xaml。 – 2010-12-20 16:05:18
我的RessourceFile名称是至今“ResourceDictionary1.xaml”。我只是试图调试和检查“this.resources”下可以看到的内容......但它是一个空字典 - 这可能也意味着为什么我没有看到任何输出。 – theXs 2010-12-20 16:06:44