Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. After changing global bool, IsEnabled property is not updating

After changing global bool, IsEnabled property is not updating

Scheduled Pinned Locked Moved WPF
csharpwpfwcfsysadmindebugging
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xtr33me
    wrote on last edited by
    #1

    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;
        }
    
    P B 2 Replies Last reply
    0
    • X xtr33me

      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;
          }
      
      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      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 the NetEnabled 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.

      My blog | My articles | MoXAML PowerToys | Onyx

      X 1 Reply Last reply
      0
      • X xtr33me

        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;
            }
        
        B Offline
        B Offline
        BechBej
        wrote on last edited by
        #3

        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

        X 1 Reply Last reply
        0
        • P Pete OHanlon

          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 the NetEnabled 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.

          My blog | My articles | MoXAML PowerToys | Onyx

          X Offline
          X Offline
          xtr33me
          wrote on last edited by
          #4

          Thanks for the help!

          P 1 Reply Last reply
          0
          • B BechBej

            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

            X Offline
            X Offline
            xtr33me
            wrote on last edited by
            #5

            Thanks for the help! Going to go try this out now.

            1 Reply Last reply
            0
            • X xtr33me

              Thanks for the help!

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              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.

              My blog | My articles | MoXAML PowerToys | Onyx

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups