views:

16

answers:

0

I need to enable/disable spell checking in a richtextbox in an ItemsControl, based on whether the RichTextBox is visible in the ItemsControl's Scrollviewer.

I think the route is to implement an IsViewPortVisible dependency property and wire an event handler for a changed event...

I found this article that describes the lengthy process for determining if an item is in the viewport:

http://social.msdn.microsoft.com/Forums/en/wpf/thread/e6ccfec3-3dc0-4702-9d0d-1cfa55ecfc90

Any ideas on where to start? I'm familiar with implementing my own dependency property for the sake of simple bindings (integers, strings, etc...). I have no idea how to undergo something like this though)

This is the end result I'm hoping for:

<DataTemplate>
<Grid>
...Stuff in the Grid
<local:CustomRichTextBox SpellCheck.IsEnabled={Binding RelativeSource={RelativeSource Self}, Path=IsViewPortVisible}/>
</Grid>
</DataTemplate>

Help will be EXTREMELY appreciated... you'll be saving me about 500MB in memory consumption while the program is running!!!! :)


EDIT


The route of binding to the SpellCheck.IsEnabled property in XAML probably won't work B/C I have additional code to run when spell check is turning on. This Part I'd just handle in the codebheind for CustomTextBox