简体   繁体   English

无法绑定数据透视表项的名称属性以标记数据透视表头模板中的文本

[英]Can't Bind name property of Pivot Item to label text in pivot header template

I have a Pivot control that uses a Datatemplate as header 我有一个使用Datatemplate作为标题的数据透视控件

In the property UriSource of the BitMapIcon AppBarButton I have binded the header property of the pivot item and I would like to bind in the Label text of the AppBarButton the property Name of the Pivot Item. 在BitMapIcon AppBarButton的属性UriSource中,我绑定了数据透视表项的header属性,我想在AppBarButton的Label文本中绑定数据透视表项的Name。 Is possible to do this? 可以这样做吗? Or how can I bind label text from the pivot item as I binding the Header to the UriSource? 还是在将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>

Thanks 谢谢

Resolved: 解决:

It was easy. 很容易。

I've just created a class with text and image properties in the Datacontext viewModel of the pivot control and binded the object to the header property of the pivot item. 我刚刚在数据透视表控件的Datacontext viewModel中创建了一个具有文本和图像属性的类,并将对象绑定到数据透视表项的header属性。

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM