gpt4 book ai didi

c# - UWP 列表框 ForEach

转载 作者:太空宇宙 更新时间:2023-11-03 22:37:27 25 4
gpt4 key购买 nike

我正在尝试循环访问 UWP 列表框。

我的 XAML:

 <ListBox x:Name="SeasonsListBox" Margin="786,24,558,863" HorizontalAlignment="Left" VerticalAlignment="Top" >
<ListBoxItem Content="2016-2017"/>
<ListBoxItem Content="2017-2018"/>
<ListBoxItem Content="2018-2019"/>
</ListBox>

下面是我的代码:

        var items = SeasonsListBox.Items;
foreach (var item in items)
{
string temp = item.ToString();
}

我正在尝试获取内容,但它不允许我item.Content.ToString()

最佳答案

你可能想试试:

string temp = (item as ListBoxItem).Content.ToString();

关于c# - UWP 列表框 ForEach,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54269826/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com