Is there any event to handle then element is visual to user?
Example: There are some UI elements in the listbox but all the items are not visual, when user scrolls the listbox then element is visual. I want to identify that visual to handle read operation.
If you use the LongListSelector, rather than a ListBox you can use the ItemRealized event to know when a virtualized item has been realized (loaded).
If you really want to know when items are visible you'll have to measure the size of the items (if they're not all the same and known in advance), the size of the area that the ListBox (or LongListSelector) takes up (it'll vary for WVGA/WXGA & 720P screens) and the ScrollOffset of the internal (to the control template) ScrollViewer to calculate which items are currently visible.
Related
i have a tab and has few pages on this tab control (say 8 pages) and each page has 2 or 3 listbox displaying some info related to that job (sales, admin, warehouse etc).
when a staff login, only the page related to their job is showing (tab page visible = false) and wondering if those listbox's row source still active (but not showing due to visible put to false)?
just wondering if affects performance due to many listbox in a form, visible or not?
thanks for reading.
Controls that are on an active, loaded form (even if they, or even the entire form, are/is not visible) can be queried against, period. Doesn't matter if they are on another tab or not. So yes, they will affect performance (likely negligibly, unless you've got thousands of or extremely complicated look-ups going on).
If the parent container(i.e a page on the tab is not visible), then all controls on the page will not be visible.
A control not visible in this instance because the parent container is not, e.g listbox, combo box, textbox, etc, does not consume memory space.
I'm developing a Windows Store App which has a gridview that is used like a "Toolbox" from which I want to be able to drag items onto another control.
The default animation of dragging removes the item from the GridView while the item is being dragged and then the item snaps back to the GridView after the item is dropped on the destination component.
Is it possible/easy to allow the item (or items in the case of multi-selection) to be shown at the mouse/touch location during the drag while also remaining within the GridView?
The quick answer is no. Especially since you said "easy way". The concept of adorners which is in WPF isn't part of WinRT. You can always create something that floats under the pointer, for sure. That's a real option. But drag and drop is only partly implemented in W8.x XAML.
I have a GridView in my main app page and I want to do some background processing for the items that are currently in view for the user (high priority), and then of course do the other items too (low priority).
I can access the ScrollBar and the ScrollViewer, but none of them appear to tell me which of my items are in the current scroll window. I could try to hack this in, but it gets tricky because the number of row/columns change based on the size of the scroll region.
http://msdn.microsoft.com/en-us/library/windows/apps/br209745.aspx
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.scrollviewer.aspx
Any help much appreciated!
thanks
There are two general ways you can do this. The first is to get the GridViewItem's AutomationPeer, which actually has a direct method to call. Class information here. I've had problems getting this to actually be usable though. Luckily, there's a second answer. It will require some math to be done, but it's doable.
Get the item container, in this case a GridViewItem, using the GridView's ItemContainerGenerator.
Get the GridView's ScrollViewer. You can search for FindVisualChild<T> methods, there are plenty around.
Do MyGridViewItem.TransformToVisual(MyGridViewScrollViewer).TransformPoint(new Point(0, 0)); This will get you the top left corner of the item, relative to the entire scrollable panel (known as its Extent) of the ScrollViewer (this will be important later).
This will return to you a Point object.
Next, we'll need to find out the range of X values that are currently being displayed in the ScrollViewer.
Note: If you're using a Vertical scrolling ScrollViewer, use the Heights. Horizontal, use the Widths. Both, use both. I am going to do my example using the Horizontal/Width.
Take the HorizontalOffset. This is your current 'lower bound' for the current viewable region.
Take the HorizontalOffset plus the ViewportWidth. This is the upper bound of the current viewable region.
If your Point.X is greater than your lower bound and less than your upper bound, then the item is visible.
If you further need to find out if the whole item is visible, do
this same calculation for Point.X + GridViewItem.Width.
Hope this helps, and happy coding!
You can use VisualTreeHelper to scan the visual tree as Nate suggests, but this is usually not recommended at runtime, especially for tight loops (e.g. checking lots of GridViewItem objects) or complex visual trees. You could do a minor improvement and only calculate the position of these items once and then do a simplified check based on the ScrollViewer.ViewChanged event and offset values, but that still seems a bit too complicated.
If your GridView uses an ItemsPanel that supports virtualization (e.g. the default WrapGrid) - most of the items that are actually loaded into GridView items are actually visible or not far off the screen, so if you bind your GridView to a collection of view models using ItemsSource - you can figure out when these items are accessed by binding to their properties or handling Loaded/Unloaded events on the ItemTemplate and call back to the view models to know when they are getting accessed. That way you can start loading these items when they first start showing up on screen and leave the logic to determine whether they should be loaded to the list control virtualization implementation in the platform.
In my Windows Phone 8 application I have use a LongListSelector control from the SDK to display hierarchical data.
How can I find out (from within my application button click handler) what the currently active (stacked on top) group header is? The SelectedItem might be null and therefore I cannot find the parent group from it.
If you don't have a selected item you'd have to use the ScrollOffset of the internal ScrollViewer to work out how much the list had been scrolled and then determine it based on the height of the items (and headers) that have been scrolled.
I'm fairly experienced with MS Access 2003, but 2007 has a new feature that is confusing me.
I'm maintaining an Access database with a variety of reports. Some of these reports have fields with constraints on where I can move them. If I move a field vertically, ALL the fields in that section must move with it. If I move a field horizontally, it automatically switches with the field next to it.
This is clearly a feature since it makes some kinds of reports easier, but it's just getting in my way now since I need to have detail fields on 2 lines. Can someone tell me what this thing is called and (more importantly) how do I turn it off?
The feature is known as "Control Layouts." Here's how to get rid of them:
Remove controls from a control layout
Removing a control from a
control layout allows you to place it anywhere on the report without
affecting the positioning of any other controls.
Select the control you want to remove from the layout. To select
multiple controls, hold down the SHIFT key and then click the controls
that you want to remove. To select all of the controls in the layout,
click the layout selector box at the top left corner of the layout.
Do
one of the following:
On the Arrange tab, in the Control Layout group,
click Remove.
Right-click one of the selected controls, point to
Layout, and then click Remove. Access removes the selected controls
from the layout.
TIP To prevent a control from being inserted into
a control layout as you move it, press and hold the CTRL key, and then
drag the control to where you want it.
The full documentation for the above excerpt can be found here: Modify, edit, or change a report