IsCurrentLineHighlightingEnabled Issue

SyntaxEditor for WPF Forum

Posted 12 years ago by Rick - Developer, Visual Software Systems LLC
Version: 11.2.0553
Platform: .NET 4.0
Environment: Windows 7 (64-bit)
Avatar

I'm having a problem with the new IsCurrentLineHighlightingEnabled property.  I have this property bound to a ribbon button, but what I'm finding is that it doesn't reliably toggle it's state with the button click. I have set the state of the property to True.  When the application starts, the the button indicates an "on" state and line highlighting is on.  When I click the button, highlighting is turned off and the button goes into an "off" state.  Now when I click the button again, the button indicates "on" but line highlighting does not get turned on.  From this point on. I can click the button and line hightlighting turns on and off, but is out of sunc with the state of the button. I have other boolean syntax editor properties bound to ribbon buttons exactly the same way, using a common method, and they all work correctly 100% of the time.  Not sure why this property is behaving differently. 

 

                        <ribbon:ButtonGroup >
                            <ribbon:Button Name="btnLineHighlight" ImageSourceSmall="/WpfApplication1;component/Resources/HighlightHS.png" Label="Highlight" IsChecked="{Binding Path=IsCurrentLineHighlightingEnabled, ElementName=Editor1}" Click="ToggleLineHighlightingButton_Click" ScreenTipHeader="Highlight Line" ScreenTipDescription="Toggle current line highlighting" />
                            <ribbon:Button ImageSourceSmall="/WpfApplication1;component/Resources/List_NumberedHS.png" Label="Line Numbers" IsChecked="{Binding Path=IsLineNumberMarginVisible, ElementName=Editor1}" Click="ToggleButton_Click" ScreenTipHeader="Line Numbers" ScreenTipDescription="Toggle line numbering" />
                        </ribbon:ButtonGroup>

 

        Private Sub ToggleButton_Click(ByVal sender As System.Object, ByVal e As ActiproSoftware.Windows.Controls.Ribbon.Controls.ExecuteRoutedEventArgs)
            e.Handled = True
            DirectCast(sender, ActiproSoftware.Windows.Controls.Ribbon.Controls.Button).IsChecked = Not DirectCast(sender, ActiproSoftware.Windows.Controls.Ribbon.Controls.Button).IsChecked
        End Sub

Comments (4)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Rick,

It's hard to say without a simple sample to debug but you are binding the IsChecked to the SyntaxEditor property and then setting it again in your ToggleButton_Click event.  My guess is that your event handler is wiping out the binding.  You should probably just be doing one or the other..


Actipro Software Support

Posted 12 years ago by Rick - Developer, Visual Software Systems LLC
Avatar

I understand what you are saying, but I don't think that's it.  I use this same pattern with IsRulerMarginVisible, IsWhitespaceVisible, and IsLineNumberMarginVisible properties and they work perfectly everytime.  I found when I was debugging this, trying to figure out what was going on, that everything worked well when I had a breakpoint in ToggleButton_Click on the line that updates the button.isChecked property.  Once I removed the breakpoint, in the same execution, the abnormal behavior resumed. 

Answer - Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Ok, thanks.  We tracked down the issue and have a fix for the next maintenance release.


Actipro Software Support

Posted 12 years ago by Rick - Developer, Visual Software Systems LLC
Avatar

Excellent.  Thanks!

The latest build of this product (v24.1.2) was released 10 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.