Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows store apps Windows应用商店中的长文件转换_Windows Store Apps_Type Conversion - Fatal编程技术网

Windows store apps Windows应用商店中的长文件转换

Windows store apps Windows应用商店中的长文件转换,windows-store-apps,type-conversion,Windows Store Apps,Type Conversion,我正在编写windows 8应用商店应用程序,出现以下问题: 我有一个绑定到对象长属性的textblock。 长值是123456789,但是在屏幕上我只看到字符1。 我该如何解决这个问题,以及为什么转换为字符串的过程不能正常工作?试试这个,告诉我它是否适合您 XAML myVm.cs public class myVm : INotifyPropertyChanged { public myVm() { col.Add(long.MaxValue);

我正在编写windows 8应用商店应用程序,出现以下问题: 我有一个绑定到对象长属性的textblock。 长值是123456789,但是在屏幕上我只看到字符1。
我该如何解决这个问题,以及为什么转换为字符串的过程不能正常工作?

试试这个,告诉我它是否适合您

XAML


myVm.cs

public class myVm : INotifyPropertyChanged
{
    public myVm()
    {
        col.Add(long.MaxValue);
        col.Add(long.MaxValue);
        col.Add(long.MaxValue);
        col.Add(long.MaxValue);
        col.Add(long.MaxValue);
        col.Add(long.MaxValue);
    }

    private ObservableCollection<long> _col = new ObservableCollection<long>();
    public ObservableCollection<long> col
    {
        get { return _col; }
        set
        {
            _col = value;
            NotifyPropertyChanged("col");
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    public void NotifyPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this,
                new PropertyChangedEventArgs(propertyName));
        }
    }
}
公共类myVm:INotifyPropertyChanged
{
公共myVm()
{
col.Add(long.MaxValue);
col.Add(long.MaxValue);
col.Add(long.MaxValue);
col.Add(long.MaxValue);
col.Add(long.MaxValue);
col.Add(long.MaxValue);
}
私有ObservableCollection_col=新ObservableCollection();
公共可观测集合
{
获取{return\u col;}
设置
{
_col=值;
通知财产变更(“col”);
}
}
公共事件属性更改事件处理程序属性更改;
public void NotifyPropertyChanged(字符串propertyName)
{
if(PropertyChanged!=null)
{
财产变更(本,
新PropertyChangedEventArgs(propertyName));
}
}
}

请发布您的代码,因为我的代码正在运行。我尝试使用最大的
long
值。我忘了说文本块在数据模板中。我可以看到我在DataTemplate中编写的所有其他属性,比如double和int,但我绑定到的long属性却看不到。模板是在GridView中编写的。最好用“尝试过的”代码更新您的问题。我知道我的应用程序中出现了什么问题。我绑定到的对象具有[Key]属性,因此它会自动变为int。
public class myVm : INotifyPropertyChanged
{
    public myVm()
    {
        col.Add(long.MaxValue);
        col.Add(long.MaxValue);
        col.Add(long.MaxValue);
        col.Add(long.MaxValue);
        col.Add(long.MaxValue);
        col.Add(long.MaxValue);
    }

    private ObservableCollection<long> _col = new ObservableCollection<long>();
    public ObservableCollection<long> col
    {
        get { return _col; }
        set
        {
            _col = value;
            NotifyPropertyChanged("col");
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    public void NotifyPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this,
                new PropertyChangedEventArgs(propertyName));
        }
    }
}