WP8 - 绑定ProgressBar可见性(WP8 - Bind ProgressBar visibility)
我有一个简单的代码,我检查了其他问题,但还没有。
我有一个应用程序,它从Web检索的xml文件中加载一些数据,然后在longlistselector中显示它。
我做到了,它的工作原理,现在我想添加一个不确定的进度条,它一直保持活动状态,直到我完成数据加载。
我将进度条包含在我的longlistselector之前的stackpanel中,并且我将其可见性限制在函数ProgressBarVisibility中(参见下面的代码)。
<phone:PivotItem Header="Status"> <StackPanel> <ProgressBar Value ="0" IsIndeterminate="True" Visibility="{Binding ProgressBarVisibility}"/> <phone:LongListSelector Margin="0,0,-12,0" ItemsSource="{Binding PivotOne}"> <phone:LongListSelector.ItemTemplate> <!-- lots of code here --> </phone:LongListSelector.ItemTemplate> </phone:LongListSelector> </StackPanel> </phone:PivotItem>
在MainViewModel.cs中,这就是我写的东西。
using System.Windows; public class MainViewModel : INotifyPropertyChanged { public MainViewModel() { this.PivotOne = new ObservableCollection<ItemViewModel>(); this.PivotTwo = new ObservableCollection<ItemViewModel>(); this.PivotThree = new ObservableCollection<ItemViewModel>(); } /// <summary> /// A collection for ItemViewModel objects. /// </summary> public ObservableCollection<ItemViewModel> PivotOne { get; private set; } public ObservableCollection<ItemViewModel> PivotTwo { get; private set; } public ObservableCollection<ItemViewModel> PivotThree { get; private set; } private string _detailPageTitle = "Default"; /// <summary> /// DetailPageTitle ritorna il titolo della pagina di dettaglio. Viene settato nella funzione che carica la pagina secondaria /// </summary> /// <returns></returns> public string DetailPageTitle { get { return _detailPageTitle; } set { if (value != _detailPageTitle) { _detailPageTitle = value; NotifyPropertyChanged("DetailPageTitle"); } } } public bool IsDataLoaded { get; private set; } private Visibility _progressBarVisibility = Visibility.Collapsed; public Visibility ProgressBarVisibility { get { return _progressBarVisibility; } set { if (value != _progressBarVisibility) { _progressBarVisibility = value; NotifyPropertyChanged("ProgressBarVisibility"); } } } private Visibility _progressBarVisibility = Visibility.Visible; public Visibility ProgressBarVisibility { get { return _progressBarVisibility; } set { if (value != _progressBarVisibility) { _progressBarVisibility = value; NotifyPropertyChanged("ProgressBarVisibility"); } } } public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(String propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (null != handler) { handler(this, new PropertyChangedEventArgs(propertyName)); } } public void LoadData() { //progressbar is visible, data not loaded this.IsDataLoaded = false; ProgressBarVisibility = Visibility.Visible; // Load Static and dynamic data -- populate the different pivots LoadStaticData(); LoadXMLFile(); // data loaded, progressbar collapsed this.IsDataLoaded = true; ProgressBarVisibility = Visibility.Collapsed; }
所以我包括了system.windows库,并使用了可见性类。 无论如何,当加载完成时,我无法让进度条消失,它会继续运行。
有什么建议吗? 我在哪里做错了?
提前致谢!
解决方案:在应用程序激活时执行loaddata,因此此时内容甚至无法呈现。
I have a simple thing to code, i checked other questions but couldn't it yet.
I have an application which loads some data from an xml file retrieved from the web, and then displays it inside a longlistselector.
I did it, it works, now i would like to add an indeterminate progressbar which stays active until I finished the data loading.
I enclosed the progressbar in a stackpanel, before my longlistselector, and i bound its visibility to the function ProgressBarVisibility (see code below).
<phone:PivotItem Header="Status"> <StackPanel> <ProgressBar Value ="0" IsIndeterminate="True" Visibility="{Binding ProgressBarVisibility}"/> <phone:LongListSelector Margin="0,0,-12,0" ItemsSource="{Binding PivotOne}"> <phone:LongListSelector.ItemTemplate> <!-- lots of code here --> </phone:LongListSelector.ItemTemplate> </phone:LongListSelector> </StackPanel> </phone:PivotItem>
In the MainViewModel.cs , that's how i wrote the thing.
using System.Windows; public class MainViewModel : INotifyPropertyChanged { public MainViewModel() { this.PivotOne = new ObservableCollection<ItemViewModel>(); this.PivotTwo = new ObservableCollection<ItemViewModel>(); this.PivotThree = new ObservableCollection<ItemViewModel>(); } /// <summary> /// A collection for ItemViewModel objects. /// </summary> public ObservableCollection<ItemViewModel> PivotOne { get; private set; } public ObservableCollection<ItemViewModel> PivotTwo { get; private set; } public ObservableCollection<ItemViewModel> PivotThree { get; private set; } private string _detailPageTitle = "Default"; /// <summary> /// DetailPageTitle ritorna il titolo della pagina di dettaglio. Viene settato nella funzione che carica la pagina secondaria /// </summary> /// <returns></returns> public string DetailPageTitle { get { return _detailPageTitle; } set { if (value != _detailPageTitle) { _detailPageTitle = value; NotifyPropertyChanged("DetailPageTitle"); } } } public bool IsDataLoaded { get; private set; } private Visibility _progressBarVisibility = Visibility.Collapsed; public Visibility ProgressBarVisibility { get { return _progressBarVisibility; } set { if (value != _progressBarVisibility) { _progressBarVisibility = value; NotifyPropertyChanged("ProgressBarVisibility"); } } } private Visibility _progressBarVisibility = Visibility.Visible; public Visibility ProgressBarVisibility { get { return _progressBarVisibility; } set { if (value != _progressBarVisibility) { _progressBarVisibility = value; NotifyPropertyChanged("ProgressBarVisibility"); } } } public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(String propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (null != handler) { handler(this, new PropertyChangedEventArgs(propertyName)); } } public void LoadData() { //progressbar is visible, data not loaded this.IsDataLoaded = false; ProgressBarVisibility = Visibility.Visible; // Load Static and dynamic data -- populate the different pivots LoadStaticData(); LoadXMLFile(); // data loaded, progressbar collapsed this.IsDataLoaded = true; ProgressBarVisibility = Visibility.Collapsed; }
So i included system.windows library, and used the visibility class. Anyway, i cannot get the progressbar to disappear when the loading is done, it keeps going.
Any suggestion? where am i doing it wrong?
Thanks in advance!
Solution: loaddata is executed on the app activation, so the content is not even rendered at that moment.
原文:https://stackoverflow.com/questions/18298263
最满意答案
<meta>
元素仅在HTML5文档的<head>
中有效( 元数据内容模型只能在<head>
)。 您应该使用HTML5 jQuery插件来传递配置数据的方法是使用可以使用.data()
从jQuery访问的data-*
属性 。所以你的标记可能是:
<div class="widget" data-foo="bar"><div>
而你的jQuery将是:
$('.widget').widget({...options...});
这将是一个函数,使用:
$.fn.widget = function (...) { return this.each(function () { ...code... options.foo = $(this).data('foo'); //gets the value 'bar' ...more code... }); };
回复OP的评论:
对于使用多少个
data-*
属性没有限制,如果仅仅是格式化,可以将它们分成多行。 白色空间以HTML压缩:<div class="widget" data-foo="bar" data-fizz="buzz" data-lorem="ipsum" ... data-xyz="abc"> ...contents... </div>
如果您有充分的理由将数据与
<div>
分开,那么您可以使用type="hidden"
的<input>
字段。当我有一个需要使用表单提交的交互式表单小部件时,我通常会使用它。The
<meta>
element is only valid in the<head>
of an HTML5 document (Metadata content model is only acceptable in the<head>
). What you should be using for an HTML5 jQuery plugin to pass configuration data is to usedata-*
attributes which can be accessed from jQuery using.data()
.So your markup could be:
<div class="widget" data-foo="bar"><div>
And your jQuery would be:
$('.widget').widget({...options...});
Which would be a function that uses:
$.fn.widget = function (...) { return this.each(function () { ...code... options.foo = $(this).data('foo'); //gets the value 'bar' ...more code... }); };
In reply to OPs comment:
There's no limit to how many
data-*
attributes you use, if it's simply for formatting, split them on multiple lines. White space is condensed in HTML:<div class="widget" data-foo="bar" data-fizz="buzz" data-lorem="ipsum" ... data-xyz="abc"> ...contents... </div>
If you have a good reason to keep the data separate from the
<div>
you could use an<input>
field withtype="hidden"
I typically use this when I have an interactive form widget that needs to be submitted with a form.
相关问答
更多-
你可以用正则表达式提取它。 类似于:/ /\]*\>(.*)\<\/body/m ^ /\]*\>(.*)\<\/body/m .*) /\]*\>(.*)\<\/body/m /\]*\>(.*)\<\/body/m - 应该返回元素中的所有内容。 $val = getData('myWebsite.html'); var reg = /\]*\>([^]*) ...
-
你可以使用其中一个本机JS ... window.onload = function() { // your code here }; 还是jQuery ...... $(document).ready(function() { // your code here }); ...确保代码在文档加载完成之前不会运行。 这解释了window.onload和$(document).ready()之间的细微差别。 另一个选择是将代码包装在一个命名函数中并在某个地方调用它,但你仍然需要将它放在这当然是根据HTML4.01 无效的 。 META标签只允许在HEAD中 (就像TITLE一样),因此通过将其放入BODY,您实际上创建无效的标记。 从粗略测试,似乎有些浏览器(例如Firefox 3.5和Safari 4)在创建文档树时将这些元素实际放在HEAD中。 这不是非常令人惊讶:浏览器已知容忍并尝试解释各种破碎的标记。 无效标记很少是一个好主意 。 浏览器的非标准处理可能会导致各种难以针对的呈现(和行为)不一致。 而不是依靠浏览器猜测,最好遵循一个标准。 我不知道搜索引擎如何反应这样的标签汤,但我 ...元素仅在HTML5文档的中有效( 元数据内容模型只能在 )。 您应该使用HTML5 jQuery插件来传递配置数据的方法是使用可以使用.data()从jQuery访问的data-*属性 。 所以你的标记可能是:
javascript创建iframe - 自动创建头部和身体标签(javascript create iframe - automatically creates head and body tags)[2022-01-30]
就我而言,它不是标准的,但受到所有常见浏览器的支持。 标准只定义了一个HTML标签,所以 document.documentElement 得到支持。 你可以检查: document.documentElement.children.length > 0 As far as I now, it's not standard, but supported by all common browsers. The standard only defines that there is a HTML tag, ...你可以按照这个问题的答案使用scrapy刮掉没有javascript代码的文本 from w3lib.html import remove_tags, remove_tags_with_content input = hxs.select('//div[@id="content"]').extract() output = remove_tags(remove_tags_with_content(input, ('script', ))) you can follow the answer on thi ...你能用Javascript更新meta和Open Graph标签吗?(Can you update meta and Open Graph tags with Javascript?)[2023-07-24]
关于OG标签,FB会以与搜索引擎机器人相同的方式查看您的页面,因此使用Javascript更改它们对于FB linter是不可见的,因为它甚至不会在您的页面上运行任何JS。 Regarding OG tags, FB sees your page the same way that search engine robots do, so changing them with Javascript will be invisible to the FB linter as it won't even run ...在body标签后钩住一些代码(Hook some code after body tags)[2022-12-06]
更换 add_action('after_body', 'sb_fb'); do_action('after_body', 'sb_fb'); 同 add_action('wp_footer', 'sb_fb'); 在你的插件文件中。 replace add_action('after_body', 'sb_fb'); do_action('after_body', 'sb_fb'); with add_action('wp_footer', 'sb_fb'); in your plugin file. ...var arrOfPtags = document.getElementsByTagName("p"); for (var i = 0;i < arrOfPtags.length; i++){ arrOfPtags[i].setAttribute("desired_attribute", "value"); } var arrOfPtags = document.getElementsByTagName("p"); for (var i = 0;i < arrOfPtags.length; i+ ...相关文章
更多- WP7 Mango可用性之我见
- wordpress wp_mail
- 微信 Windows Phone版原型设计 - [WP开发]
- 微信公众平台接口开发WP博客插件 Ⅰ [来源:我爱水煮鱼]
- 新闻:小娜来了 微软语音助手正式入华
- 《Windows Phone 7.5专题讲座之WP7入门系列》共10课时/更新完毕[压缩包]
- JavaFx Main中怎么绑定Java类中的一个static变量呢?
- Hadoop http address绑定内网地址
- 微信5.0绑定银行卡教程
- [转]android高仿微信UI点击头像显示大图片效果
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)