Question

Minu7 on Mon, 04 Aug 2014 18:14:42


Hi,

I have a grid view populated with my own data source. And i display it as a horizontal list of items in fullscreen view.

In snapped views, I show it as vertical view with list of items. When i do so, my item template definition is to have only the tiltle display in the vertical list and the grid containing all details will be hidden. When, title is clicked, the border that holds the grid will be displayed.

Question:

Is there a way to dynamically identify the first item alone and expand it (that is, set border's visibility to true) so that the first item alone is displayed in a detailed view?

For instance, lets say i have 5 items A,B,C,D,E

A- ComputerA

Adata1

Adata2...Adatan

B-Computer B

Bdata1 ---- Bdatan

Now in snap view, I'll show just A-ComputerA, B-Computer B. When user clicks on A, I'll show Adata1...Adatan

I will now need to automatically expand and show A's content alone, can you please throw some light on how this could be done?

Thanks!


Sponsored



Replies

Rob Caplan [MSFT] on Tue, 05 Aug 2014 20:09:41


Can you explain what you are doing more clearly?

Typically the pattern I think you're following would be done by having separate GridView (for horizontal) and ListView (for vertical) each bound to the same underlying data. Each control can have its own item template showing data appropriate for the view.

--Rob

Minu7 on Thu, 07 Aug 2014 17:44:18


I have 2 gridviews (even for a vertical view) with same data source groups as you said.

Now let me talk about the vertical gridview

My item template will show a header that will have just abstract information. Beneath it i will have one more border containing a grid that will hold more information. I will keep that hidden and will expand that on item click.

Now my question is, how would i get to expand the first item(i mean the border containing grid that is present beneath the header) automatically. All i want to achieve here is to show the users that these are expandable, by expanding that one item.

Thaks!

Sharif Nezar on Sun, 17 Aug 2014 18:25:17


If the GridViews are containing your own custom types you could implement INotifyPropertyChanged, add a new property, bind this property to the Border's visibility with a OneWay binding(as opposed to a OneTime binding), then add a handler to the vertical GridView, for example on the event Loaded or SizeChanged, then alter this property in said handler.  If you need access to the first element you can access it via
GridView^ g1 = safe_cast<GridView^>(sender);
YourType^ yt1 = safe_cast<YourType^>(g1->Items->GetAt(0));

where sender is the first argument of your event handler