gpt4 book ai didi

c# - 我如何使用 mvvm 显示 Windows Phone 8 应用程序的加载栏

转载 作者:行者123 更新时间:2023-11-30 13:16:54 27 4
gpt4 key购买 nike

如何从 View 模型中调用加载栏?很酷的一个,上面有漂浮的小点。我似乎找不到合适的 Bing 短语来搜索它。

最佳答案

试试这个。

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));
}
}
}

关于c# - 我如何使用 mvvm 显示 Windows Phone 8 应用程序的加载栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19554262/

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