【发布时间】:2021-03-16 02:47:29
【问题描述】:
我创建了一个商店列表,将其添加到选择器中,但从视图中它没有加载。它显示了一个没有项目的选择器。
ViewModel代码如下
public List<string> Stores = new List<string>
{
"store 1",
"store 2",
"store 3"
};
private int _selectedStoreIndex = -1;
public int SelectedStoreIndex
{
get { return _selectedStoreIndex; }
set
{
if (_selectedStoreIndex != value)
{
_selectedStoreIndex = value;
UpdateStoreSelection();
OnPropertyChanged();
}
}
}
Xaml 文件
<Picker ItemsSource="{Binding Stores}" SelectedIndex="{Binding SelectedStoreIndex}"/>
【问题讨论】:
-
您好,您可以查看Lifecycle methods 以在
OnStart/OnSleep/OnResume中添加计时器来计算运行时间。
标签: xamarin xamarin.forms picker