I have a "Details View" that needs to be shared among other views.
An example of a view that uses the "Details View"
This code is in a UserControl
ParentView.xaml
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*" Name="detailsRowDefinition"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0"...>
<StackPanel Grid.Row=1 HorizontalAlignment="Center">
<!--This is what I'd like to get ActualHeight from-->
<!--I've tried to get ActualHeight from the RowDefinition as well-->
<ContentControl Name="detailsView" Content="{Binding Details}"/>
</StackPanel>
</Grid>
Then another xaml file make sure that the {Binding Details} in the ContentControl
above work correctly, and it renders my DetailsView correctly.
Now, in another file DetailsView.xaml
(also a UserControl)
<TabControl>
<TabItem Header="Part A">
<!--This is the blasted ScrollViewer that I can't set the height on-->
<ScrollViewer Height="{Binding Path=ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=RowDefinition}}" >
<!--Lots of crap-->
</ScrollViewer>
</TabItem>
<TabItem Header="Part B">
</TabItem>
<!--etc-->
<TabControl>
I've tried different variations of binding like ElementName
and setting AncestorLevel
really high, etc.
The answer I'm going for is like this one: How to make scrollviewer work with Height set to Auto in WPF? Except that I need to bind to the parent element of the UserControl that this
UserControl is embedded in
The answer on this question seems like what I'm trying to do, but there's no help in terms of code snippets.How can I get the actual grid row height of a grid with RowDefinition Height *