What do I need to do to bind a shape's properties to a custom class or structure's properties?For some reason my object is not updating with changes in the source. The initial value is bound okay, but updating doesn't seem to occur. Here is an illustrative sample code:<br/> <br/> (See next post for the code; formatting screwed up)<br/>© 2009 Microsoft Corporation. All rights reserved.Sat, 04 Jul 2009 06:05:31 Zba93922e-f7c7-4846-ac43-d8c9631dd14dhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ba93922e-f7c7-4846-ac43-d8c9631dd14d#ba93922e-f7c7-4846-ac43-d8c9631dd14dhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ba93922e-f7c7-4846-ac43-d8c9631dd14d#ba93922e-f7c7-4846-ac43-d8c9631dd14dDakkonAhttp://social.msdn.microsoft.com/Profile/en-US/?user=DakkonAWhat do I need to do to bind a shape's properties to a custom class or structure's properties?For some reason my object is not updating with changes in the source. The initial value is bound okay, but updating doesn't seem to occur. Here is an illustrative sample code:<br/> <br/> (See next post for the code; formatting screwed up)<br/>Fri, 03 Jul 2009 19:14:56 Z2009-07-03T22:43:30Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ba93922e-f7c7-4846-ac43-d8c9631dd14d#a1fd577a-c55a-4be9-8372-01348656f94fhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ba93922e-f7c7-4846-ac43-d8c9631dd14d#a1fd577a-c55a-4be9-8372-01348656f94fGuenter Schwaigerhttp://social.msdn.microsoft.com/Profile/en-US/?user=Guenter%20SchwaigerWhat do I need to do to bind a shape's properties to a custom class or structure's properties?Hi DakkonA,<br/><br/>you have to repost your sample code formatted! I have tried to import the VB code in VS but it's impossible to make it run. Try it yourself.<br/><br/>You can format your VB.Net code with the icon &lt;/&gt; (right of the HTML icon) in the editor.<br/><br/><br/>By the way why do you using a Structure and not a Class for the CustomStructure?<br/><br/>Hope it helps.Fri, 03 Jul 2009 22:30:08 Z2009-07-03T22:30:08Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ba93922e-f7c7-4846-ac43-d8c9631dd14d#42ff19a4-1358-4e77-8abe-14b803a89331http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ba93922e-f7c7-4846-ac43-d8c9631dd14d#42ff19a4-1358-4e77-8abe-14b803a89331DakkonAhttp://social.msdn.microsoft.com/Profile/en-US/?user=DakkonAWhat do I need to do to bind a shape's properties to a custom class or structure's properties?I added the code formatted using that function, and when I edited my post it broke. And when I tried to fix it, it didn't work. Let me try again here.<br/> <br/> I'm actually not entirely sure of the details of when to use a structure vs. a class, though I read that structures were more efficient, and didn't see any particular drawbacks, at least that I could understand.<br/> <br/> XAML:<br/> <pre lang=x-xml>&lt;Window x:Class=&quot;Window1&quot; xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot; xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot; Title=&quot;Window1&quot; Height=&quot;300&quot; Width=&quot;300&quot;&gt; &lt;Grid&gt; &lt;Rectangle x:Name=&quot;TestShape&quot; Stroke=&quot;Black&quot; /&gt; &lt;Button HorizontalAlignment=&quot;Left&quot; VerticalAlignment=&quot;Bottom&quot; x:Name=&quot;ChangeButton&quot;&gt;Change&lt;/Button&gt; &lt;TextBlock HorizontalAlignment=&quot;Right&quot; VerticalAlignment=&quot;Bottom&quot; x:Name=&quot;CurrentMarginTextBlock&quot; /&gt; &lt;/Grid&gt; &lt;/Window&gt;</pre> <br/> <br/> Code-Behind:<br/> <pre lang=x-vbnet>Class Window1 Public CustomStructureInstance As New CustomStructure Private Sub Window1_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded CustomStructureInstance.Margin = 50 CurrentMarginTextBlock.Text = CStr(CustomStructureInstance.Margin) Dim MarginBinding As New Binding MarginBinding.Source = CustomStructureInstance MarginBinding.Path = New PropertyPath(&quot;Margin&quot;) TestShape.SetBinding(Rectangle.MarginProperty, MarginBinding) End Sub Private Sub ChangeButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles ChangeButton.Click CustomStructureInstance.Margin = CustomStructureInstance.Margin + 10 CurrentMarginTextBlock.Text = CStr(CustomStructureInstance.Margin) End Sub End Class Public Structure CustomStructure Implements System.ComponentModel.INotifyPropertyChanged Private MarginPrivate As Double Public Property Margin() As Double Get Return MarginPrivate End Get Set(ByVal value As Double) If Not value = MarginPrivate Then MarginPrivate = value NotifyPropertyChanged(&quot;Margin&quot;) End If End Set End Property Private Sub NotifyPropertyChanged(ByVal info As String) RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(&quot;info&quot;)) End Sub Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged End Structure </pre> <br/>Fri, 03 Jul 2009 22:42:19 Z2009-07-03T22:42:19Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ba93922e-f7c7-4846-ac43-d8c9631dd14d#67fbf752-11b6-40a0-a6e8-69d32179728ahttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ba93922e-f7c7-4846-ac43-d8c9631dd14d#67fbf752-11b6-40a0-a6e8-69d32179728aGuenter Schwaigerhttp://social.msdn.microsoft.com/Profile/en-US/?user=Guenter%20SchwaigerWhat do I need to do to bind a shape's properties to a custom class or structure's properties?Hi DakkonA,<br/><br/>thats much better :)<br/><br/>You have a bug in your NotifyProperyChanged method. You always fireing the event with &quot;info&quot;. That says to WPF, hey the info property has changed. But you want &quot;Margin&quot;.<br/><br/>Second, you can not use a structure you have to use a class.<br/><br/> <pre lang=x-vbnet>Public Class CustomStructure Implements System.ComponentModel.INotifyPropertyChanged Private MarginPrivate As Double Public Property Margin() As Double Get Return MarginPrivate End Get Set(ByVal value As Double) If Not value = MarginPrivate Then MarginPrivate = value NotifyPropertyChanged(&quot;Margin&quot;) End If End Set End Property Private Sub NotifyPropertyChanged(ByVal info As String) RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(info)) End Sub Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged End Class</pre> Hope this helps.Fri, 03 Jul 2009 23:18:55 Z2009-07-03T23:18:55Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ba93922e-f7c7-4846-ac43-d8c9631dd14d#dd61e062-1308-4777-b22c-2e02efd8988bhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ba93922e-f7c7-4846-ac43-d8c9631dd14d#dd61e062-1308-4777-b22c-2e02efd8988bDakkonAhttp://social.msdn.microsoft.com/Profile/en-US/?user=DakkonAWhat do I need to do to bind a shape's properties to a custom class or structure's properties?Thanks Guenter! The &quot;info&quot; error actually wasn't in my real code, but changing my structures to classes fixed the problem.Sat, 04 Jul 2009 06:05:31 Z2009-07-04T06:05:31Z