无法将数据透视项的名称 属性 绑定到数据透视表 header 模板中的标签文本
Can't Bind name property of Pivot Item to label text in pivot header template
我有一个使用 Datatemplate 作为 header
的 Pivot 控件
在 BitMapIcon AppBarButton 的 属性 UriSource 中,我绑定了枢轴项的 header 属性,我想在 AppBarButton 的标签文本中绑定 属性 数据透视项的名称。
可以这样做吗?或者如何在将 Header 绑定到 UriSource 时绑定数据透视项中的标签文本?
<PivotItem Width="360" Name="Home" Header="ms-appx:///Assets/AppBar/Home.png" DataContext="{Binding MainViewModel.HomeModel}" ContentTemplate="{StaticResource HOMEList}" />
<DataTemplate x:Key="PivotHeader" >
<Grid Background="{StaticResource AppForegroundColor}">
<AppBarButton Label="{Binding Name}"> (doesn't work)
<AppBarButton.Icon>
<BitmapIcon UriSource="{Binding}"/> (gets header prop)
</AppBarButton.Icon>
</AppBarButton>
</Grid>
</DataTemplate>
谢谢
已解决:
很简单。
我刚刚在 pivot 控件的 Datacontext viewModel 中创建了一个带有文本和图像属性的 class,并将 object 绑定到 header 属性主项。
谢谢
我有一个使用 Datatemplate 作为 header
的 Pivot 控件在 BitMapIcon AppBarButton 的 属性 UriSource 中,我绑定了枢轴项的 header 属性,我想在 AppBarButton 的标签文本中绑定 属性 数据透视项的名称。 可以这样做吗?或者如何在将 Header 绑定到 UriSource 时绑定数据透视项中的标签文本?
<PivotItem Width="360" Name="Home" Header="ms-appx:///Assets/AppBar/Home.png" DataContext="{Binding MainViewModel.HomeModel}" ContentTemplate="{StaticResource HOMEList}" />
<DataTemplate x:Key="PivotHeader" >
<Grid Background="{StaticResource AppForegroundColor}">
<AppBarButton Label="{Binding Name}"> (doesn't work)
<AppBarButton.Icon>
<BitmapIcon UriSource="{Binding}"/> (gets header prop)
</AppBarButton.Icon>
</AppBarButton>
</Grid>
</DataTemplate>
谢谢
已解决:
很简单。
我刚刚在 pivot 控件的 Datacontext viewModel 中创建了一个带有文本和图像属性的 class,并将 object 绑定到 header 属性主项。
谢谢