How do we pass the BindingContext
of a DataTemplate
as a CommandParameter
when parent has a separate BindingContext
?
Normally I just do CommandParameter={Binding .}
but because the parent view has it's own BindingContext
it passes that context through. Hopefully this makes sense.
Example XAML code:
<DataTemplate x:Key="dataTemplateRoot" x:DataType="models:ThoughtEntryContainer">
<StackLayout
x:Name="NTStackLayout"
HeightRequest="{Binding MaxHeight}">
<Editor
Text="{Binding thought}">
<Editor.Behaviors>
<xct:EventToCommandBehavior Command="{Binding Path=BindingContext.SetHeightsCommand, Source={x:Reference rootView}}" EventName="SizeChanged">
<xct:EventToCommandBehavior.CommandParameter>
<MultiBinding Converter="{StaticResource MultiConverter}">
<Binding Source="{x:Static models:ThoughtEntryType.NegativeThought}" />
<Binding Source="{Binding .}" /> <!-- This is where I want to pass dataTemplateRoot's BindingContext -->
<Binding Source="{x:Reference NTStackLayout}" />
</MultiBinding>
</xct:EventToCommandBehavior.CommandParameter>
</xct:EventToCommandBehavior>
</Editor.Behaviors>
</Editor>
</StackLayout>
</DataTemplate>