views:

11

answers:

0

Hi.

I have the following code XAML code.

<Grid>
    <code:TSScrollViewer x:Name="scrollViewer" Zoomer="{Binding ElementName=zoomer}">
        <code:DesignerCanvas x:Name="designerCanvas" Background="white" />
    </code:TSScrollViewer>

    <code:TSZoomer x:Name="zoomer" Grid.Row="0" Grid.Column="1" ControlToZoom={Binding ElementName=designerBorder} "/>
</Grid>

I have a DesignerCanvas control that I want to be able to Zoom in/out on. So I created the TSZoomer control and gave it a dependency property 'ControlToZoom', so I could bind any control to the Zoomer and let it handle the zooming. It workes great.

When I did the zoom, the object became to large for the window so I wrapped it in a scrollviewer so I could move around and see whole zoomed object. It worked great too.

But the problem was the the scrollbars didn't react as I wanted on the zoom so I wanted to connect my zoomControll to my scrollviewer so it could listen for an event raised by the zoomer and the calculate out the position of the scrollbars. So I created the 'Zommer' dependencyproperty and tried to bind my Zoomer to the scrollviewer.

And hers where I run into problem, since the zoomer isnt' created yet when the scrollviewer is created my zoomerproperty in my scrollviewer will always be NULL. And if I but the Zoomer before the Scrollviewer in the XAML-code. My 'ControlToZoom' in my Zommer will be NULL.

How can I fix this, one way is to put the ScrollViewer into the Zoomer, but I don't like that way. Must be a way to solve this problem...

Thanks!