Know when UIElement is shown on screen

Hi there,
So I have a wrap panel with a scrollbar and I'm putting a bunch of controls in them.  I would like to perform actions when the controls become visible (are scrolled into view), either just for the first time or any time.
Is there a way to detect when a UI element is either on screen and visible or off screen and not visible?
Many thanks in advance.
Somewhere out there...

Hi Barry,
Unfortunately that code is also not useful for my requirement as it specifically requires that I pass the object in that I want to know is visible or not.  If I have a wrappanel with 2000 items in, that would be unusable.  I have found an alternative
method of getting the top left item and bottom right item that are in view every time the scroll changes of the parent scroll viewer.
private Int32 FindTopLeftImageViewerIndex()
ImageViewer pIVrTopLeft = null;
Int32 pIntX = 0;
Int32 pIntY = 0;
for (pIntY = 0; pIntY <= 20; pIntY+=2)
for (pIntX = 0; pIntX <= 200; pIntX+=10)
IInputElement pIEtElement = ThumbnailScrollViewer.InputHitTest(new Point(pIntX, pIntY));
if (pIEtElement != null)
if (pIEtElement.GetType() != typeof(ScrollViewer))
pIVrTopLeft = GetParentImageViewer(pIEtElement);
if (pIVrTopLeft != null)
return (cLisImages.IndexOf(pIVrTopLeft));
return (-1);
private Int32 FindBottomRightImageViewerIndex()
//Get top left item
ImageViewer pIVrBottomRight = null;
Int32 pIntX = 0;
Int32 pIntY = 0;
Int32 pIntMaxX = (Int32)ThumbnailScrollViewer.ActualWidth;
Int32 pIntMaxY = (Int32)ThumbnailScrollViewer.ActualHeight;
for (pIntY = pIntMaxY; pIntY >= (pIntMaxY - 100); pIntY -= 10)
for (pIntX = pIntMaxX; pIntX >= 2; pIntX-=2)
IInputElement pIEtElement = ThumbnailScrollViewer.InputHitTest(new Point(pIntX, pIntY));
if (pIEtElement != null)
if (pIEtElement.GetType() != typeof(ScrollViewer))
pIVrBottomRight = GetParentImageViewer(pIEtElement);
if (pIVrBottomRight != null)
return (cLisImages.IndexOf(pIVrBottomRight));
return (cLisImages.Count - 1); //Assume the last thumbnail is in view
private ImageViewer GetParentImageViewer(IInputElement iElement)
FrameworkElement pFEtCurrent = (FrameworkElement)iElement;
while (pFEtCurrent.GetType() != typeof(ImageViewer))
pFEtCurrent = (FrameworkElement)pFEtCurrent.Parent;
if (pFEtCurrent == null)
return (null);
ImageViewer pIVrViewer = (ImageViewer)pFEtCurrent;
return (pIVrViewer);
The user control I am inserting is a custom one called an ImageViewer, as in this context I am displaying thumbnails.  The code to find an input control at a specific point returns the child controls of this usercontrol so I have a method that walks
the parent stack to find the owner control.
Once I have the indexes of the first and last item in view I can then perform tasks on them as opposed to doing it the second they are added to the control which just adds unnecessary overhead.
Somewhere out there...

Similar Messages

  • Does anyone know when Macbook Airs had matte screens?

    I own a mid-2011 13" Macbook Air.  I purchased this computer through th Apple website and went through all of the customization options maxing out whatever was available to me. At the time, there was the option to choose a matte or a glossy screen (this is not offered now - just glossy). I chose matte because I had heard about eye strain stories and was uninterested in a glossy screen, especially one just created with a coating (not glass). I have used my computer ever since and it definitely had a matte, anti-glare screen. Nothing like the glossy screens that are offered now. I recently had the screen replaced due to some problems, but they replaced it with a glossy screen. The Apple store is now insisting that it is impossible I ever had a matte screen, as it was never offered, and that I am just making this up, or too stupid to know what screen I was using for 2.5 years, or that it's actually the same screen and I just think it's glossy now because it's "new". I am extremely upset that I'll have to be using a glossy screen now, but more upset at the way Apple has treated me over this.
    I wanted to see if anyone else has a non-glossy Macbook Air screen (not a screen protector/anti-glare filter cover thing) or knows anyone who does. My screen did not have the sharp reflections that it does now, I saw it next to a glass screen every day that I used it and the difference was striking.  I could sometimes get the purplish not-sharp reflections that did not impede viewing, but nothing like it has now. If anyone else had/has a screen on their macbook air that was anti-glare/matte, please let me know. I know that the Apple Support page for this model of computer states it is only offered in glossy (then, and now).

    From
    MacBook Air - Wikipedia
    and
    MacBook Air Tech Specs
    it does not appear that MacBook Air has ever had a matte screen.
    Maybe the nature of the glossy screen has changed since 2011?

  • When printing slides with notes, only notepart shown on screen is included

    Hi
    I make presentations with really long presenters notes. During presentation I can scroll the presenters notes on screen with U and D, but my problem is when printing the slides with notes, only the part of the notes that is shown on screen is printing, so I sometimes half of the note section on a slide.
    Is there a work around, or is it just the way life is?
    Thanks in advance.

    I too am having the same issue. I am trying to print out a monthly calendar like I see on the screen. At the most on any given day I have 4 lines of text. It shows on the screen but when I print it puts 3 little dots above that particular day to let me know there is more to it and refuses to print more than 3 items. I have tried with different page set ups and all I am doing is wasting ink. What's worse, is that there is PLENTY of room left on the paper. There is so much room between the month label and where the calendar starts there certainly has to be a way to adjust this. (I would hope!) Anyone please help! Thanks in advance.

  • When i take a partial screen shot i do not know where it goes, when i take a partial screen shot i do not know where it goes because it dose not go to my desk top and i cant find it in the search thing... but i can hear it being taken

    when i take a partial screen shot i do not know where it goes, when i take a partial screen shot i do not know where it goes because it dose not go to my desk top and i cant find it in the search thing... but i can hear it being taken

    an oh! one more thing, you can change the default folder or create a new one to store all screenshots. Also you can change the file format. Look at the following links
    http://hints.macworld.com/article.php?story=20050824073301844
    http://guides.macrumors.com/Taking_Screenshots_in_Mac_OS_X

  • When i get a call unknown is shown on screen even if the number is saved in my phone

    when i get a call unknown is shown on screen even if the number is saved

    Caller ID is a carrier feature & the number must match exactly what is entered in your contact listing.

  • I am having trouble with my iphone, I updated it and when I turned on the screen the ituns and USB icon appear. I've tried to restore it but it sends me to the ituns icon right away and I dont know what to do.

    I am having trouble with my iphone, I updated it and when I turned on the screen the ituns and USB icon appear. I've tried to restore it but it sends me to the ituns icon right away and I dont know what to do.

    you may have to do these stepps a few times http://support.apple.com/kb/HT1808

  • I activated voice over and screen display is not shown and when touched, says time and "screen locked"

    activated voice over and screen display is not shown and when touched, says time and "screen locked"

    Hi muhsinmuhmmed,
    If you are having issues with Voice Over and a locked screen, you may find the following discussion helpful:
    Apple Support Communities: My iPad is locked and I can't type since VoiceOver is active.
    https://discussions.apple.com/thread/3933512
    Regards,
    - Brenden

  • I left my macbook pro closed and when I came back the screen had a huge crack all over the screen, anyone know why this could have happened?

    I left my macbook pro closed and when I came back the screen had a huge crack all over the screen, anyone know why this could have happened?

    Someone dropped something onto your computer.
    Someone pressed on the closed computer.
    Someone placed heavy objects on your computer.
    We can only guess since the someone was not us and we were not there when it happened.

  • How do I know when my backup is complete to my external hard drive

    How do I know when my back up is complete to an external har drive...new user

    Welcome to Apple Support Communities.
    If you are using Time Machine, open , System Preferences, System, Time Machine.
    It will show the status of the backup drive, including the date of the first backup, as well as the most recent.
    Checkmarking the 'Show Time Machine status in the menu bar' will allow you to view the latest Time Machine backup by clicking on the icon in the menu bar, without going through System Preferences each time.
    Clicking Open Time Machine Preferences... from the menubar takes you to the same Preference screen as shown above.
    The first backup will take a while, up to several hours or more, because it is a complete backup of everything on your system.

  • After installing Maverick my computer, when restarted, only a gray screen appeared. My computer won't work at all...what happened?

    After installing Maverick my computer shut down and when it restarted I couldn't get to the home screen. The monitor was grey with some dark grey shapes, it sounded like it was constantly running a program. My computer is sick!! HELP

    Take each of these steps that you haven't already tried. Stop when the problem is resolved.
    Step 1
    The first step in dealing with a startup failure is to secure the data. If you want to preserve the contents of the startup drive, and you don't already have at least one current backup, you must try to back up now, before you do anything else. It may or may not be possible. If you don't care about the data that has changed since the last backup, you can skip this step.   
    There are several ways to back up a Mac that is unable to start. You need an external hard drive to hold the backup data.
         a. Start up from the Recovery partition, or from a local Time Machine backup volume (option key at startup.) When the OS X Utilities screen appears, launch Disk Utility and follow the instructions in this support article, under “Instructions for backing up to an external hard disk via Disk Utility.”
    b. If you have access to a working Mac, and both it and the non-working Mac have FireWire or Thunderbolt ports, start the non-working Mac in target disk mode. Use the working Mac to copy the data to another drive. This technique won't work with USB, Ethernet, Wi-Fi, or Bluetooth.
    c. If the internal drive of the non-working Mac is user-replaceable, remove it and mount it in an external enclosure or drive dock. Use another Mac to copy the data.
    Step 2
    If the startup process stops at a blank gray screen with no Apple logo or spinning "daisy wheel," then the startup volume may be full. If you had previously seen warnings of low disk space, this is almost certainly the case. You might be able to start up in safe mode even though you can't start up normally. Otherwise, start up from an external drive, or else use either of the techniques in Steps 1b and 1c to mount the internal drive and delete some files. According to Apple documentation, you need at least 9 GB of available space on the startup volume (as shown in the Finder Info window) for normal operation.
    Step 3
    Sometimes a startup failure can be resolved by resetting the NVRAM.
    Step 4
    If you use a wireless keyboard, trackpad, or mouse, replace or recharge the batteries. The battery level shown in the Bluetooth menu item may not be accurate.
    Step 5
    If there's a built-in optical drive, a disc may be stuck in it. Follow these instructions to eject it.
    Step 6
    Press and hold the power button until the power shuts off. Disconnect all wired peripherals except those needed to start up, and remove all aftermarket expansion cards. Use a different keyboard and/or mouse, if those devices are wired. If you can start up now, one of the devices you disconnected, or a combination of them, is causing the problem. Finding out which one is a process of elimination.
    Step 7
    If you've started from an external storage device, make sure that the internal startup volume is selected in the Startup Disk pane of System Preferences.
    Start up in safe mode. Note: If FileVault is enabled, or if a firmware password is set, or if the startup volume is a Fusion Drive or a software RAID, you can’t do this. Post for further instructions.
    Safe mode is much slower to start and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know the login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    When you start up in safe mode, it's normal to see a dark gray progress bar on a light gray background. If the progress bar gets stuck for more than a few minutes, or if the system shuts down automatically while the progress bar is displayed, the startup volume is corrupt and the drive is probably malfunctioning. In that case, go to Step 10. If you ever have another problem with the drive, replace it immediately.
    If you can start and log in in safe mode, empty the Trash, and then open the Finder Info window on the startup volume ("Macintosh HD," unless you gave it a different name.) Check that you have at least 9 GB of available space, as shown in the window. If you don't, copy as many files as necessary to another volume (not another folder on the same volume) and delete the originals. Deletion isn't complete until you empty the Trash again. Do this until the available space is more than 9 GB. Then restart as usual (i.e., not in safe mode.)
    If the startup process hangs again, the problem is likely caused by a third-party system modification that you installed. Post for further instructions.
    Step 8
    Launch Disk Utility in Recovery mode (see Step 1.) Select the startup volume, then run Repair Disk. If any problems are found, repeat until clear. If Disk Utility reports that the volume can't be repaired, the drive has malfunctioned and should be replaced. You might choose to tolerate one such malfunction in the life of the drive. In that case, erase the volume and restore from a backup. If the same thing ever happens again, replace the drive immediately.
    This is one of the rare situations in which you should also run Repair Permissions, ignoring the false warnings it may produce. Look for the line "Permissions repair complete" at the end of the output. Then restart as usual.
    Step 9
    Reinstall the OS. If the Mac was upgraded from an older version of OS X, you’ll need the Apple ID and password you used to upgrade.
    Step 10
    Do as in Step 9, but this time erase the startup volume in Disk Utility before installing. The system should automatically restart into the Setup Assistant. Follow the prompts to transfer the data from a Time Machine or other backup.
    Step 11
    This step applies only to models that have a logic-board ("PRAM") battery: all Mac Pro's and some others (not current models.) Both desktop and portable Macs used to have such a battery. The logic-board battery, if there is one, is separate from the main battery of a portable. A dead logic-board battery can cause a startup failure. Typically the failure will be preceded by loss of the settings for the startup disk and system clock. See the user manual for replacement instructions. You may have to take the machine to a service provider to have the battery replaced.
    Step 12
    If you get this far, you're probably dealing with a hardware fault. Make a "Genius" appointment at an Apple Store, or go to another authorized service provider.

  • When I open Mail the screen flickers random blue and gray appeared on the screen. I took a video too. Will that happen again? Is it hardware problem? This ipad2 32GB was replaced yesterday and I think it is refurbished. Are replace product refurbished?

    I got my ipad2 replaced yesterday. And this new ipad started giving me problem by crashing aps. Then I restored the ipad twice but the problem was still there. I called apple and they fixed it by doing Reset All Settings. But now I have this weird problem. When I open Mail the screen flickers random blue and gray appeared on the screen. I took a video too. Will that happen again? Is it hardware problem? This ipad2 32GB was replaced yesterday and I think it is refurbished. Are replace product refurbished?

    There is no way for anyone here to know if your replacement iPad is a refurbished unit.  Per Apple's replacement policy, replacements can be refurbished units.  If you feel the unit is not working correctly, take it back, let them check it out and if found defective, they will replace that unit.

  • When I go into full screen mode in Safari 5.1 on LION it switches to a new Space, making my other displays useless. Anyone else annoyed that Apple has completely left out those with multiple displays?

    I had a fear that this was going to be the case, but you can't have two full screen apps open in two different displays. At least that's how Safari fullscreen works. When switching over to full screen mode in safari, it automatically creats a new space, turns on four finger gesture to swipe through full screen apps which I had turned off in place of App Switcher.
    I don't use spaces because of the lack of support for using spaces with multiple displays. I would use spaces and mission control if I had control of each display's mission control separately.
    The fix would be to unlink the displays so they can scroll through full screen apps by themselves. I want this feature so I can mix and match the full screen apps on my three different displays. I see this beneficial for more people with multiple displays. in the future when thunderbolt display links, people will want better support too.
    I know I would use spaces and mission control more if I could have this ability. I'd be interested to know people's opinion.

    No no, if you read what I said, it would be that each individual display would be customizable to the user. The way you have it, it sounds like your second display will be dedicated to scrolling through fullscreen apps not allowing you to do it on the home screen. This is silly because with my concept, you could do that, by dragging apps to fullscreen in your second display, but if you want you could tell another display to scroll through fullscreen apps (independently) if you wanted. Each display will have it's own mission control with it's own set of desktops. I also can see how some people would still want them linked together, so this could just be a little check box made in mission control prefs to "link" or "unlink" desktops with link checked by default.
    With your solution you're limited to your setup. but what if the person has three or four displays? Well then your solution would limit them to one dedicated display that scrolls through fullscreen apps where mine lets a person customize their desktops depending on their preference and setup.
    further example: if you have safari, address book and mail in one display, you could still have ichat, PS and Illustrator in your second, and a text editor, FTP Client and iTunes in your third. Then you would mix and match these apps but it would promote the use of mulitple displays as well as benefit people with three or more, which thunderbolt, Cinema Display and Pro computers support.

  • My Iphnoe 4 was stolen, what can i do?, how to know when it's block by IMEI

    I'm travelling across argentina, and a couple of days ago some one stolen my Iphone in my room in KAIXO CENTRAL HOSTEL, (never go there!!!, there is an YHA hostel close to this, and there are security, I learn of my mistakes, later...).
    I want to know when my Iphone it's blocked, any know how to confirm that the phone it's blocked??? , I call to apple support and send all the stuff to block my phone, at least i don't want who some one use it or see my personal data, photo, music...
    when the Iphone it's blocked by IMEI, this device can do anything???
    Thanks in advance.

    If the carrier has blocked the IMEI, all that means is that the iPhone will not be able to connect to the cell network. That does not prevent someone from accessing the data or trying to hack the iPhone to work around the block. If you set a passcode on the screen lock, that makes it more difficult for someone to use the iPhone without erasing your information, but it's not impossible.
    In any case, there's nothing you can do about it now, not unless you set up Find My iPhone and it can locate the iPhone in which case you can let the police know the reported location and, if you wish, wipe the iPhone (note though that if you wipe it, you will get no further location information). Change all passwords to online services you had set up or used from the iPhone.
    Regards.

  • Folder or File path when f4 option on selection screen is clicked

    can any one please let me know if there is a function module which can fetch folder name form the directory path when f4 option of selection screen field is selected. Currently I am able to get the file name using FM F4_DXFILENAME_4_DYNP but the requirment is like I have to select either folder name or the file name depending on user selection.

    HI
    use the following
    FORM GETFILE.
      CALL FUNCTION 'WS_FILENAME_GET'
       EXPORTING
        DEF_FILENAME           = ' '
         DEF_PATH               = '.'
        MASK                   = ' '
        MODE                   = ' '
        TITLE                  = ' '
       IMPORTING
         FILENAME               = TXT_FILE
        RC                     =
      EXCEPTIONS
        INV_WINSYS             = 1
        NO_BATCH               = 2
        SELECTION_CANCEL       = 3
        SELECTION_ERROR        = 4
        OTHERS                 = 5
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    <b>TMP_GUI_DIRECTORY_LIST_FILES</b>
    Retrieve all of the files and subdirectories on the Presentation Server (PC) for a given directory.
    Example:
    data:  lc_directory         like bdschko16-target_dir value 'C:\TEMP\',
           lc_filter(20)        type c default '.'.
           li_file_count        type i,
           li_dir_count         type i,
           ltab_dir_table       like sdokpath occurs 0 with header line,
           ltab_file_file_table like sdokpath occurs 0 with header line.
    call function 'TMP_GUI_DIRECTORY_LIST_FILES'
      exporting
        directory        = lc_directory
        filter           = lc_filter  importing
        file_count       = li_file_count
        dir_count        = li_dir_count
      tables
        file_table       = ltab_file_table
        dir_table        = ltab_dir_table
      exceptions
        cntl_error       = 1
        others           = 2.
    regards vijay

  • What does it mean when your whole i phone screen turns green

    What does it mean when your whole iphone 5 screen turns green

    It means that you jailbroke your iPhone with redsn0w. There are several known methods to fixing this issue:
    1. Plug it into your computer and restore
    2. Plug it into your computer, then hold the power button for about 6 seconds
    3. Hold the power button and the home button to restart it. As soon as it turns on, plug it into your computer and wait
    4. Time. Sometimes it fixes itself over time.
    I would suggest refraining from jailbreaking your device next time. I know it tempting to do so, but if you want to root your phone or play with emulators, I would suggest an android device. Btw, iOS 7 looks promising for the Apple community. Keep your ears peeled this week during WWDC.

Maybe you are looking for

  • I messed up my CSS styles, should I just start over?

    I've been working on a template for a couple weeks. And I changed a couple CSS styes by creating new ones. I didn't really know what I was doing, and now my template's navigation bar has disappeared and my main background has shortened up and is comp

  • Compressed formats won't play in CD player

    Is there any compressed audio format I can use to burn a CD which will play in my CD players? I've tried most of the formats that iTunes offers, and none of them seem to work. Also: I've been burning onto CD-RWs, not CD-Rs. Does this matter? Thanks i

  • Exception Not Handled.

    Hi all, Can you please explain why the exception is not handled even thought i have handled it by mentioning others. declare procedure empnetsal (vempno emp.empno%type) is netsal number; begin select sal into netsal from emp where empno = vempno; net

  • Connecting laptop to desktop

    Can I connect my macBook to my iMac, sort of like an external hard drive, so I can pull large files off it? If so, what cable/port should I use? iMac G5   Mac OS X (10.4.5)   iMac G5   Mac OS X (10.4.5)  

  • Change default image names

    I'm not finding much regarding the new iOS with this question. We have the need to change the default photo name to date and time stamps on the iPhone 4S.. using the lates iOS... is this possible? I'm not seeing any way to change image names at all o