问题
As per @Justin XL's answer to this question (Overriding Pivot header foreground brushes in UWP app) you can style the Pivot Header in XAML (as per his code, below).
Having done this in XAML, how would you then programmatically change something (e.g. the Foreground) dynamically using C#?
<Grid>
<Pivot Title="Pivot">
<Pivot.HeaderTemplate>
<DataTemplate>
<Grid>
<TextBlock Text="{Binding}" Foreground="Teal" />
</Grid>
</DataTemplate>
</Pivot.HeaderTemplate>
<PivotItem Header="My first header">
<Grid/>
</PivotItem>
</Pivot>
</Grid>
Update: Currently I only have 3 pivot items (tabs) and they are all set in the XAML, but the user can change the style (Foreground & Background) - updating the UI to match their changes is simple enough - except for the pivot headers.
来源:https://stackoverflow.com/questions/37669908/how-to-access-pivot-header-template-dynamically-i-e-using-c