Print Page | Close Window

How to create a "viewport" with Markup/XAML?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=24047
Printed Date: 29 April 2024 at 12:27am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to create a "viewport" with Markup/XAML?
Posted By: rvoith
Subject: How to create a "viewport" with Markup/XAML?
Date Posted: 08 September 2020 at 3:37am
The setting is that I have a large image displayed in a markup control with a an Image-tag. I would like to display only a portion of it by using a "viewport" (in lack of a better word). 

I'll try to illustrate this below, where you see the view port focusing on a part of the larger image;
Viewport in action on a larger image

The viewport itself only displays what the coordinates specifies, and would look like this;
Just the viewport

I have tried to fiddle around with the XAML-elements Canvas, ScrollViewer, Viewbox and Image, but with no current success yet. Somehow I feel that the attributes ClipToBound on Image could be useful, but I seem to lack something like VerticalOffset and HorizontalOffset combined with Height and Width.

Does anybody have any ideas on how to create a viewport?


-------------
Best regards,
Bob
Proud Programmer!



Replies:
Posted By: jpbro
Date Posted: 08 September 2020 at 3:49pm
Something like this appears to work:

<Page xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' >
    <Border Width='200' Height='200' ClipToBounds='True'>
            <Image Source="file://<PATH TO YOUR IMAGE>" Margin='-100,-100,0,0'/>
        </Border>
</Page>

By fixing the Border width and setting ClipToBounds='True', you create a fixed size viewport. By setting the Left & Right margins to negative numbers, you can move the enclosed image around the viewport.


-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: rvoith
Date Posted: 09 September 2020 at 2:22am
jpbro!! This works!! Thank you for trying this out!!

-------------
Best regards,
Bob
Proud Programmer!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net