Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - How to create a "viewport" with Markup/XAML?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

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

 Post Reply Post Reply
Author
Message
rvoith View Drop Down
Groupie
Groupie
Avatar

Joined: 03 July 2003
Location: Norway
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote rvoith Quote  Post ReplyReply Direct Link To This Post Topic: How to create a "viewport" with Markup/XAML?
    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!
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (1) Thanks(1)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
rvoith View Drop Down
Groupie
Groupie
Avatar

Joined: 03 July 2003
Location: Norway
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote rvoith Quote  Post ReplyReply Direct Link To This Post Posted: 09 September 2020 at 2:22am
jpbro!! This works!! Thank you for trying this out!!
Best regards,
Bob
Proud Programmer!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.