I donβt have the courage to say this is a mistake, although I still think that I played around this problem, which takes me like one week:
First: This is not only for the BottomAppBar , TopAppBar experiencing the same problem.
Second: The problem is that the ElementName binding ElementName works when your source element is an element that is inside one of the AppBars, which means:
- From
BottomAppBar (target) to TopAppBar (source): Works - From
BottomAppBar (target) to BottomAppBar (source): Works - From
TopAppBar (target) to BottomAppBar (source): Works - From
TopAppBar (target) to TopAppBar (source): Works - From
TopAppBar (target) to something outside two AppBars (source): doesn't work - From
BottomAppBar (target) to something outside two AppBars (source): not working
Example:
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> <TextBox x:Name="text" MinWidth="200" MinHeight="40" VerticalAlignment="Center" HorizontalAlignment="Center"/> </Grid> <Page.TopAppBar> <AppBar> <StackPanel Orientation="Horizontal"> <Button Content="{Binding Text, ElementName=text}" Click="Button_Click_1"></Button> <Button Content="{Binding Text, ElementName=text2}" Click="Button_Click_1"></Button> <TextBox x:Name="text3" MinWidth="200" MinHeight="40" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBox x:Name="text3" MinWidth="200" MinHeight="40" VerticalAlignment="Center" HorizontalAlignment="Center"/> </StackPanel> </AppBar> </Page.TopAppBar> <Page.BottomAppBar> <AppBar> <StackPanel Orientation="Horizontal"> <Button Content="{Binding Text, ElementName=text}" Click="Button_Click_1"></Button> <Button Content="{Binding Text, ElementName=text3}" Click="Button_Click_1"></Button> <TextBox x:Name="text2" MinWidth="200" MinHeight="40" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBox x:Name="text3" MinWidth="200" MinHeight="40" VerticalAlignment="Center" HorizontalAlignment="Center"/> </StackPanel> </AppBar> </Page.BottomAppBar>
The contents of the first button in both AppBars will not show anything, but the second button of both of the AppBars will display correctly.
I found out that the only thing AppBar sees from the outside is the DataContext root element of the Page , so think about using the backing property in the DataContext to handle all this, this works great for me
source share