Hi @Nathan Sokalski ,
The Windows Runtime does not provide a way to register a custom dependency property as read-only.
The alternative solution are as follows.
Public Class TestUserControl
Inherits UserControl
Public ReadOnly Property Value As Double
Get
Return _Value
End Get
End Property
Private _Value As Double = 1
End Class
Public Class TestReadonlyUserControl
Inherits UserControl
Public Property Value As Double
Get
Return CType(GetValue(ValueProperty), Double)
End Get
Private Set(value As Double)
SetValue(ValueProperty, value)
End Set
End Property
Protected Shared ReadOnly ValueProperty As DependencyProperty _
= DependencyProperty.Register _
("Value" _
, GetType(Double) _
, GetType(TestReadonlyUserControl) _
, New PropertyMetadata(CType(1, Double))
)
Public Sub New()
Dim g As New Grid()
g.Background = New SolidColorBrush(Windows.UI.Colors.Red)
AddHandler g.Tapped, Sub()
Me.Value += 1
End Sub
Me.Content = g
Me.Width = 100
Me.Height = 100
End Sub
End Class
---
<StackPanel>
<local:TestReadonlyUserControl x:Name="uc" />
<TextBlock Text="{Binding ElementName=uc, Path=Value}" />
</StackPanel>