Archive for May 17th, 2007
Dave’s Layout Framework
Dave Relyea just blogged about prototype of layout framework that he has been playing around.
Fixes for Sample ScrollViewer
I was trying to use Sample ScrollViewer shipped as part of Controls sample pack in SDK for Silverlight Alpha 1.1. There are few bugs that I thought people will come across…
Clipping issue
Same as ListBox Clipping Issue, Control seems to set the clip on the wrong object. Fix is also the same.
In the UpdateLayout method, you need to change following line…
Clip = clip;
to
ActualControl.Clip = clip;
ScrollViewer.Content is not initialized
ScrollViewer.Content property is not initialized. So if you try to add children to Content, it will throw an exception. so when you use ScrollViewer, you need to initialize it. Instead of fixing this in control, i just fixed the code where i need to use ScrollViewer.
so constructor for the control that uses ScrollViewer looks like this…
scrollviewer = rootCanvas.FindName("scrollviewer") as ScrollViewer; scrollviewer.Content = new Canvas();
ValueRange is not set at UpdateLayout time
ValueRange is only set when the content property is set. But Content height and width can change and so should range property. So I copied following piece of code from Setter of content property to UpdateLayout function. This means that I need to set the height/width of content before I set height/width of ScrollViewer because that is when UpdateLayout gets called.
if (horizontalScrollBar != null) { horizontalScrollBar.Range = new ValueRange(0, content.Width); } if (verticalScrollBar != null) { verticalScrollBar.Range = new ValueRange(0, content.Height); }
So my app code looks like this…
scrollviewer.Content.Height = ItemHeight * _numberOfRows; scrollviewer.Height = Height;
scrollviewer.Content.Width = ItemWidth * _numberOfColumns; scrollviewer.Width = Width;