Reputation: 5005
I have a simple Page
with a TextBlock
where I want to display its ActualHeight
and ActualWidth
.
<Page
x:Class="HaproPlace2.Views.Calibration.CalibrationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="1080"
d:DesignWidth="1920"
x:Name="Page1">
<Grid>
<TextBlock Text="{Binding ElementName=Page1, Path=ActualHeight}" Foreground="LimeGreen" />
</Grid>
</Page>
When the app
starts, it shows the right value, but is not updating when resizing the page/window
. Is there something special in uwp
to get it automatically updating the ui
if bound to a dependencyProperty
via ElementName
?
Upvotes: 0
Views: 150
Reputation: 821
You are not Using Mode=TwoWay
, mandatory in order to have the value update constantly.
Upvotes: 0
Reputation: 7851
See the note here.
Although it [ActualHeight] has an ActualHeightProperty backing field, ActualHeight does not raise property change notifications and it should be thought of as a regular CLR property and not a dependency property.
So your options are:
SizeChanged
of Page and update your Text from thereUpvotes: 2