【发布时间】:2013-11-02 11:19:04
【问题描述】:
如何从视图模型中调用加载栏?很酷的一个,上面有漂浮的小圆点。我似乎找不到合适的 Bing 短语来搜索它。
【问题讨论】:
-
我相信它们被称为不确定的进度条。很多谷歌搜索结果。希望对您有所帮助。
标签: c# mvvm windows-phone-8
如何从视图模型中调用加载栏?很酷的一个,上面有漂浮的小圆点。我似乎找不到合适的 Bing 短语来搜索它。
【问题讨论】:
标签: c# mvvm windows-phone-8
您正在寻找的是一个不确定的进度条。
您可以从系统托盘[3] 调用内置进度条,也可以从工具箱中在 XAML 中定义一个自定义进度条。
对于虚线效果,您只需将 Progress Bar 的 Indeterminate 属性设置为 True ,否则它将显示一个进度条,显示进程完成的百分比。
这里有一些有用的文章供您参考:
【讨论】:
【讨论】:
试试这个。
XAML
<phone:PhoneApplicationPage
...............>
<phone:PhoneApplicationPage.DataContext>
<local:ViewModel/>
</phone:PhoneApplicationPage.DataContext>
<shell:SystemTray.ProgressIndicator>
<shell:ProgressIndicator IsIndeterminate="{Binding IsBusy}"
IsVisible="{Binding IsBusy}"
Text="{Binding Message}" />
</shell:SystemTray.ProgressIndicator>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
<TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Content="Show Progress" Command="{Binding _ShowProgressBar}" Height="100" />
</Grid>
</Grid>
</phone:PhoneApplicationPage>
C#
public class ViewModel : INotifyPropertyChanged
{
private bool _IsBusy;
public bool IsBusy
{
get { return _IsBusy; }
set { _IsBusy = value; RaisePropertyChanged("IsBusy"); }
}
private string _Message;
public string Message
{
get { return _Message; }
set { _Message = value; RaisePropertyChanged("Message"); }
}
public RelayCommand _ShowProgressBar { get; set; }
public ViewModel()
{
_ShowProgressBar = new RelayCommand(() => ShowProgressBar());
}
private void ShowProgressBar()
{
IsBusy = true;
Message = "Loading...";
}
public event PropertyChangedEventHandler PropertyChanged;
private void RaisePropertyChanged(string property)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
}
}
【讨论】: