|
I used http://msdn.microsoft.com/en-us/library/cc189066(VS.95).aspx this code to move an object only and wondered how can I do this with the entire canvas. I took a look at your code and replaced
Rectangle item = sender as Rectangle;
with yours:
FrameworkElement element = sender as FrameworkElement;
and it happened. Thanks!
|
|
|
|
|
I need to determine whether the FlowDocument inside a RichTexBox fits without exceeding the height of the RichTextBox. If I could get an event that announces that the vertical scroll bar is visible when VerticalScrollBarVisibility="Auto" , that would do the trick, but I haven't been able to discover how to do that. Likewise a property giving me the computed height of the content would also do it, but I don't seem to be able to get that, either. Any other way? What I want to do is to be able to bring up a resizable window containing the content if the content exceeds the actual height and width of the RichTextBox.
|
|
|
|
|
I believe you can see if the control "requires scrolling" after setting the content. Sorry I can't be more detailed in my answer, but it was a few months ago that I was dealing with scrolling.
EDIT - You may have to add a handler for the ContentRendered event for the control because the necessary properties may not be set until the content is rendered. I'm not sure about this though.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
modified on Sunday, November 1, 2009 7:18 AM
|
|
|
|
|
John Simmons / outlaw programmer wrote: I believe you can see if the control "requires scrolling" after setting the content.
The "content" of a RichTextBox is a FlowDocument which is a ContentElement, but I don't see any properties that specify whether a ContentElement "requires scrolling." Likewise for the derived class, RichTextBox. What event could I look for that would tell me that?
John Simmons / outlaw programmer wrote: You may have to add a handler for the ContentRendered event for the control because the necessary properties may not be set until the content is rendered. I'm not sure about this though.
In MSDN, I could only find two classes that receive a ContentRendered event: Window and Frame, and RichTextBox isn't derived from either, and so the ContentRendered event doesn't show up as an event that RichTextBox can receive.
If there were a way to get the ScrollViewer from the RichTextBox, that would give me something else to investigate, but I don't see how you can do that, either.
|
|
|
|
|
If you knew the name of the scroller element, you could get it that way. I believe it's "PART_ContentHost".
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: If you knew the name of the scroller element, you could get it that way. I believe it's "PART_ContentHost".
You're getting into an area that is obscure to me. If the name of my RichTextBox is richTB , my first guess for getting at the scroller element was this:
ScrollViewer sv = richTB.PART_ContentHost;
But it didn't compile. How would I code the line that retrieves the ScrollViewer control? And in general, how do you find out the names of all the components of a control? That would enable me to verify whether PART_ContentHost is indeed the name of the RichTextBox ScrollViewer.
|
|
|
|
|
Try this:
ScrollViewer sv = (ScrollViewer)richBox.Template.FindName("PART_ContentHost", richBox);
You can't do this in the form's constructor. Either do it in the form's Loaded or ContentRendered handler.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Thank you very much! That worked! I learned something new today. Now I have | | | |