Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow binding to HeaderTemplate and ContentTemplate of material:TabItem #663

Open
StepKie opened this issue May 6, 2024 · 0 comments
Open

Comments

@StepKie
Copy link
Sponsor Contributor

StepKie commented May 6, 2024

In our code, we wanted to reuse a named DataTemplate that was defined in our Styles.xaml:

<DataTemplate x:Key="TabHeaderTemplate" x:DataType="material:TabItem">
        <Label
            Padding="0,0,0,5"
            HorizontalOptions="Center"
            VerticalOptions="Center"
            LineBreakMode="MiddleTruncation"
            Text="{Binding Title}">
            <Label.Triggers>
                <DataTrigger Binding="{Binding IsSelected}" TargetType="Label" Value="True">
                    <Setter Property="TextColor" Value="{StaticResource Primary}" />
                    <Setter Property="Scale" Value="1.2" />
                </DataTrigger>
                <DataTrigger Binding="{Binding IsSelected}" TargetType="Label" Value="False">
                    <Setter Property="TextColor" Value="Gray" />
                    <Setter Property="Scale" Value="1" />
                </DataTrigger>
            </Label.Triggers>
        </Label>
    </DataTemplate>

and apply as an implicit style it as a default to all TabItem s like so:

<Style TargetType="material:TabItem">
  <Setter Property="HeaderTemplate" Value="{StaticResource TabHeaderTemplate}" />
</Style>

Currently, this is not possible, since TabItem.cs does not expose its properties DataTemplate and ContentTemplate as BindableProperties.

#662 would enable this possibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant