0

I have Binding a ObservableCollection to ItemSource. And I set the Item Header Property Style to binding a string.

I want it can display the Header Like Page 1, Page 2 etc.. according to the binding object index. How Can I do something in the TabControl_Header' get function in VM Class?

View

<Style x:Key="_HeaderString" TargetType="TabItem">
      <Setter Property="Header" Value="{Binding DataContext.TabControl_Header , Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
</Style>

ViewModel

public string TabControl_Header
{
    get { return "Page_"+???; }            
}
ASh
  • 34,632
  • 9
  • 60
  • 82
楊子慶
  • 3
  • 1
  • I would say that the object you set in your TabItem show have that info. and when you create the collection you pass the corresponding index to the element. – sexta13 Mar 21 '16 at 14:08
  • check this out: http://stackoverflow.com/questions/22378456/how-to-get-the-index-of-the-current-itemscontrol-item – sexta13 Mar 21 '16 at 14:13

0 Answers0