I am trying to bind the width of my columns within a DataGrid to an application settings property. I have this working when binding is set to OneWay mode however, I need the setting to be updated based on the width of the column when the app closes. When I change the binding mode to TwoWay, the binding breaks all together. My code is below, how can I go about achieving this?
Extension Class
Public Class SettingBindingExtension
Inherits Binding
Public Sub New()
Initialize()
End Sub
Public Sub New(ByVal path As String)
MyBase.New(path)
Initialize()
End Sub
Private Sub Initialize()
Me.Source = MySettings.[Default]
'OneWay mode works for the initial grid load but any resizes are unsaved.
Me.Mode = BindingMode.OneWay
'using TwoWay mode below breaks the binding...
'Me.Mode = BindingMode.TwoWay
End Sub
End Class
xaml
xmlns:w="clr-namespace:Stack"
<DataGrid>
...
<DataGridTextColumn Header="STACK"
Width="{w:SettingBinding StackColumnWidth}"/>
...
</DataGrid>