How to access Pivot Header Template Dynamically (i.e. using C#)

与世无争的帅哥 提交于 2019-12-13 06:30:22

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!