Closed StefanoRivolta-Previero closed 4 years ago
@StefanoRivolta-Previero The vertical layout uses an ItemsControl
for the steps. That's why the DataContext
in the vertical layout is set to the item. The horizontal layout uses a single ContentControl
only and thus the DataContext
will be as you expected.
This binding should work for both layouts:
Text="{Binding Path=DataContext.Test, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type mde:Stepper}}}"
I modified the code in the Demo project, in StepperControl.xaml like this:
And in StepperBaseViewModel I've added a Test property as follows:
When the layout is set to horizontal, it works as expected. When the layout is set to vertical, it doesn't work anymore, like this: