小编use*_*835的帖子

如何在XAML中用StringFormat显示逗号分隔的数字?

我的代码目前显示如下:43521 reviews我希望它是这样的:43,521 reviews.我怎样才能做到这一点?是否有所有可能格式的完整参考StringFormat?找不到任何东西.谢谢.

<TextBlock Text="{Binding Reviews,StringFormat='{}{0} reviews'}"/>
Run Code Online (Sandbox Code Playgroud)

c# xaml string-formatting windows-phone windows-phone-8

8
推荐指数
3
解决办法
7455
查看次数

解析xml字符串时,XDocument.Element返回null

我有这个xml字符串:

<a:feed xmlns:a="http://www.w3.org/2005/Atom" 
        xmlns:os="http://a9.com/-/spec/opensearch/1.1/"
        xmlns="http://schemas.zune.net/catalog/apps/2008/02">
    <a:link rel="self" type="application/atom+xml" href="/docs" />
    <a:updated>2014-02-12</a:updated>
    <a:title type="text">Chickens</a:title>
    <a:content type="html">eat 'em all</a:content>
    <sortTitle>Chickens</sortTitle>
    ... other stuffs
    <offers>
        <offer>
            <offerId>8977a259e5a3</offerId>
            ... other stuffs
            <price>0</price>
            ... other stuffs
        </offer>
    </offers>
    ... other stuffs
</a:feed>
Run Code Online (Sandbox Code Playgroud)

并希望获得价值,<price>但在我的代码中:

XDocument doc = XDocument.Parse(xmlString);
var a = doc.Element("a");
var offers = a.Element("offers");
foreach (var offer in offers.Descendants())
{
   var price = offer.Element("price");
   var value = price.Value;
}
Run Code Online (Sandbox Code Playgroud)

doc.Element("a");返回null.我试过删除该行offers也是null.我的代码有什么问题以及如何获得价值price?谢谢

c# xml linq

6
推荐指数
2
解决办法
6898
查看次数

如何访问Windows Phone 8.1中的下载文件夹

我想将文件下载到Downloads文件夹并阅读.它是一个像照片和视频的根文件夹.

Windows.Storage.DownloadsFolder不适用于手机,我看不出它KnownFoldersWindows.Storage.KnownFolders.PicturesLibrary;

我也试过C:\Data\Users\Public\Downloads\它会给出一个未经授权的结果.

我看到有些应用可以访问它,但是怎么样?

c# windows-phone windows-phone-8 windows-phone-8.1 win-universal-app

5
推荐指数
1
解决办法
8128
查看次数

如何排序字符串列表?

我有一份人员名单 List<person>

public class Person
{
    public string Age { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

他们的年龄可悲,string但实际上是类型,int并且具有类似的价值"45", "70", "1" etc..如何从旧到年轻的列表排序?

呼叫people.Sort(x => x.Age);不会产生预期的结果.谢谢.

c# linq sorting

4
推荐指数
2
解决办法
70
查看次数

如何在Windows Phone 8.1中缓存页面

以前在Windows Phone 8.0应用程序中,我们可以通过这种方式更深入地浏览同一页面:

NavigationService.Navigate(new Uri("/SamePage.xaml", UriKind.Relative));
Run Code Online (Sandbox Code Playgroud)

页面自动缓存,因此在导航回来后,用户离开时列表上的位置相同.

但是Windows Phone Store Apps我们以这种方式深入到同一页面:

Frame.Navigate(typeof(SamePage), id);
Run Code Online (Sandbox Code Playgroud)

但是在导航回来之后它会再次加载数据,所以如果用户位于长列表的中间位置,那么现在他位于顶部:

private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
{
    // TODO: Create an appropriate data model for your problem domain to replace the sample data.
    var group = await SampleDataSource.GetGroupAsync((string)e.NavigationParameter);
    this.DefaultViewModel["Group"] = group;
}
Run Code Online (Sandbox Code Playgroud)

如何像以前那样缓存页面,这样用户将在他离开的列表中的相同位置?

(我也包括Windows应用程序,因为他们从较长时间就熟悉它).

c# xaml windows-phone-8 windows-store-apps windows-phone-8.1

4
推荐指数
1
解决办法
4788
查看次数

如何为派生类实现INotifyPropertyChanged?

我有一个基类:

public class PersonBaseClass : INotifyPropertyChanged
{
    private string name;
    public string Name
    {
        get { return name; }
        set
        {
            if (value != name)
            {
                name = value;
                NotifyPropertyChanged("Name");
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

和派生类

public class TeacherClass : PersonBaseClass, INotifyPropertyChanged
{
    private string id;
    public string Id
    {
        get { return id; }
        set
        {
            if (value != id)
            {
                id = value;
                NotifyPropertyChanged("Id");
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

而这个神奇的代码在每个上面的结尾!

    public event PropertyChangedEventHandler PropertyChanged;
    private void NotifyPropertyChanged(String propertyName)
    {
        PropertyChangedEventHandler …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml windows-runtime windows-phone-8

2
推荐指数
1
解决办法
2309
查看次数

文本框仅大写

我想要TextBox唯一的大写字母。在 Windows Phone 中它没有CharacterCasing,我能想到的唯一解决方案是:

private void textBox_TextChanged(object sender, TextChangedEventArgs e)
{
   textBox.Text = textBox.Text.ToUpper();
}
Run Code Online (Sandbox Code Playgroud)

每次用户按下一个不好的键时,它都会执行该过程。有没有更好的办法?

c# windows-phone-7 windows-phone windows-phone-8

1
推荐指数
1
解决办法
3601
查看次数