teynon
teynon

Reputation: 8298

WPF ListView Button Inherit Font Color

I'm trying to make an "invisible" button in a listview column. How can I get a button to inherit the font color from the ListViewItem?

<ListView x:Name="lvHistory" ItemsSource="{Binding history}" BorderThickness="0" Margin="0,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="2" util:GridViewSort.AutoSort="True" SizeChanged="lvHistory_SizeChanged">
    <ListView.View>
        <GridView>
            <GridViewColumn Width="Auto">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <Button Click="cell_click" Tag="{Binding Serial}" Foreground="{INHERITSOMETHING}">

Upvotes: 0

Views: 103

Answers (1)

user2201501
user2201501

Reputation:

This will bind the button's foreground to the same as the ListViewItem

Foreground="{Binding Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}}"

Upvotes: 2

Related Questions