简体   繁体   中英

Windows Store App GridView get total width

I'm building a Windows Store App that uses a GridView to show a list of items (basic, out of the box template). I would like to know if I can get the total width that all the items take up.

Right now I'm taking the number of item columns and multiplying it by the total width of one of the items. This is working, but it requires that my code behind knows way too much about my view. I'd like to find the one property that has the width and just bind to it.

Thanks for any help!

Here is the code that I have to get the column width of the GridView

(itemGridView.ItemContainerGenerator.ContainerFromIndex(0) as GridViewItem).ActualWidth

I don't have a good way to get the number of Columns, so that would also be helpful

The ActualWidth property of the GridView should contain the information you are looking for.

If not, you could try to call Measure on the gridview to let it perform the required layout calculus and output its desired Size.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM