Content update - XAML loading and dependency properties (user story 1878471) (#1257)

* Add article, toc, and redirects

* Add info on use of a callback to run custom logic and resolve merge conflicts
This commit is contained in:
Tris Shores
2022-01-05 14:43:43 -08:00
committed by GitHub
parent 58f6e05c13
commit cf371fba4c
20 changed files with 525 additions and 9 deletions
@@ -8,7 +8,17 @@
Public Sub New()
InitializeComponent()
' Test code.
Dim aquarium As New Aquarium With {
.AquariumGraphic = New Uri("http://www.contoso.com/aquarium-graphic-new.jpg")
}
Debug.WriteLine($"Aquarium graphic: {aquarium.AquariumGraphic}")
End Sub
' Output:
' OnUriChanged http://www.contoso.com/aquarium-graphic-new.jpg
' Aquarium graphic: http://www.contoso.com/aquarium-graphic-new.jpg
End Class
Public Class Aquarium
@@ -30,7 +40,7 @@
propertyChangedCallback:=New PropertyChangedCallback(AddressOf OnUriChanged)))
'</RegisterDependencyProperty>
' Declare a read-write property.
' Declare a read-write property wrapper.
Public Property AquariumGraphic As Uri
Get
Return CType(GetValue(AquariumGraphicProperty), Uri)
@@ -42,8 +52,8 @@
'</RegisterDependencyPropertyWithWrapper>
Private Shared Sub OnUriChanged(dependencyObject As DependencyObject, e As DependencyPropertyChangedEventArgs)
Dim shape As Shape = CType(dependencyObject, Shape)
shape.Fill = New ImageBrush(New BitmapImage(CType(e.NewValue, Uri)))
Dim value As Uri = CType(dependencyObject.GetValue(AquariumGraphicProperty), Uri)
Debug.WriteLine($"OnUriChanged: {value}")
End Sub
End Class