After changing global bool, IsEnabled property is not updating
-
I am using WPF .Net 4.0 and I have a Window that populates a number of controls with data from a file. These are all within a DockingManager ContentControl which I then have its IsEnabled property bound to a global boolean variable. Now when the window first loads, it is correctly enabled or disabled based on what default value I set to it. However when I select "Edit Network" from my context menu, I update the global bool, which does update when I put a breakpoint, but the ContentControls IsEnabled property does not get set. Any ideas as to why this may be? Is there a view update I need to call or something?
<ContentControl Name="contentCtrlValues"
syncfusion:DockingManager.Header="Current Values"
syncfusion:DockingManager.CanAutoHide="False"
Visibility="Visible"
syncfusion:DockingManager.State="Document"
syncfusion:DockingManager.CanDock="False"
syncfusion:DockingManager.CanFloat="False" IsEnabled="{Binding Path=NetEnabled,
ElementName=window1, Mode=TwoWay}">private Boolean bNetIDEnabled = false; public Boolean NetEnabled { get { return bNetIDEnabled; } set { bNetIDEnabled = value; } } private void HandleEditNetwork(object sender, RoutedEventArgs e) { NetEnabled = true; }
-
I am using WPF .Net 4.0 and I have a Window that populates a number of controls with data from a file. These are all within a DockingManager ContentControl which I then have its IsEnabled property bound to a global boolean variable. Now when the window first loads, it is correctly enabled or disabled based on what default value I set to it. However when I select "Edit Network" from my context menu, I update the global bool, which does update when I put a breakpoint, but the ContentControls IsEnabled property does not get set. Any ideas as to why this may be? Is there a view update I need to call or something?
<ContentControl Name="contentCtrlValues"
syncfusion:DockingManager.Header="Current Values"
syncfusion:DockingManager.CanAutoHide="False"
Visibility="Visible"
syncfusion:DockingManager.State="Document"
syncfusion:DockingManager.CanDock="False"
syncfusion:DockingManager.CanFloat="False" IsEnabled="{Binding Path=NetEnabled,
ElementName=window1, Mode=TwoWay}">private Boolean bNetIDEnabled = false; public Boolean NetEnabled { get { return bNetIDEnabled; } set { bNetIDEnabled = value; } } private void HandleEditNetwork(object sender, RoutedEventArgs e) { NetEnabled = true; }
You actually need to raise a notification to tell the binding object that the property has changed. This relies on you using the
INotifyPropertyChanged
interface and raising a PropertyChanged event naming theNetEnabled
property."WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
I am using WPF .Net 4.0 and I have a Window that populates a number of controls with data from a file. These are all within a DockingManager ContentControl which I then have its IsEnabled property bound to a global boolean variable. Now when the window first loads, it is correctly enabled or disabled based on what default value I set to it. However when I select "Edit Network" from my context menu, I update the global bool, which does update when I put a breakpoint, but the ContentControls IsEnabled property does not get set. Any ideas as to why this may be? Is there a view update I need to call or something?
<ContentControl Name="contentCtrlValues"
syncfusion:DockingManager.Header="Current Values"
syncfusion:DockingManager.CanAutoHide="False"
Visibility="Visible"
syncfusion:DockingManager.State="Document"
syncfusion:DockingManager.CanDock="False"
syncfusion:DockingManager.CanFloat="False" IsEnabled="{Binding Path=NetEnabled,
ElementName=window1, Mode=TwoWay}">private Boolean bNetIDEnabled = false; public Boolean NetEnabled { get { return bNetIDEnabled; } set { bNetIDEnabled = value; } } private void HandleEditNetwork(object sender, RoutedEventArgs e) { NetEnabled = true; }
-
You actually need to raise a notification to tell the binding object that the property has changed. This relies on you using the
INotifyPropertyChanged
interface and raising a PropertyChanged event naming theNetEnabled
property."WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
OK You have two ways to do that, you either implement the INotifyPropertyChanged interface or simply change this CLR property to dependency property to let wpf handle notification
-
You are welcome. Good luck.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.