标签: windows-runtime

C#WinRT Type类缺少函数

我正在尝试将一些代码移植到WinRT/Metro,我遇到了一个问题,我不确定该解决的问题.似乎Type缺少IsPrimitive和IsSubclassOf(myClass)等的访问函数.有谁知道如何在Windows 8中获得此功能?

c# microsoft-metro windows-runtime

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

从Windows应用商店应用中的后台任务进行文件访问

我似乎无法从Windows应用商店的后台任务中读取文件.这是读取文件内容的代码:

async private static Task<string> ReadAsync(string FileName)
{
    var folder = ApplicationData.Current.LocalFolder;
    var file = await folder.GetFileAsync(FileName);
    Windows.Storage.Streams.IRandomAccessStreamWithContentType inputStream = null;
    try
    {
        inputStream = await file.OpenReadAsync();
    }
    catch (Exception ex)
    {
        throw (ex);
    }
    string content = string.Empty;
    using (Stream stream = inputStream.AsStreamForRead())
    {
        using (StreamReader reader = new StreamReader(stream))
        {
            try
            {
                // *** program exits on this line
                content = await Task.Run(() => reader.ReadToEnd());
            }
            catch(Exception ex)
            {
                // no error is caught
                content = ex.Message;
            } …
Run Code Online (Sandbox Code Playgroud)

c# windows-runtime winrt-xaml winrt-async windows-store-apps

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

XNA游戏中的解决方案

我打算玩XNA游戏.

Windows商店有两个基本分辨率,它建议你支持:1024x768和1366x768

但在那之后没有任何限制.

常见的建议是使用ViewBox来扩展您的内容.

但是XNA游戏没有视图框.它有一个绘制方法,您可以在其中呈现内容.

游戏(XNA或DirectX)适应不同分辨率的常用方法是什么?

我宁愿不必为每个和evey分辨率制作图像.这将是很多工作,我一定会想念一些.

有没有更好的办法?

c# xna windows-runtime

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

访问WinRT中的Windows下载文件夹

根据这篇文章,我们只对Download文件夹有写访问权限 - 这似乎得到了我发现的支持.在WinRT中有什么方法吗?我希望能够遍历下载文件夹中的文件.

filesystems windows-8 windows-runtime

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

我究竟做错了什么?在构造函数中使用Dependency属性的值

我在使用依赖属性方面遇到了一些问题.我想使用DP的值来初始化构造函数中的对象.

问题是Month始终为0(在构造时间期间),这会导致ExpenseDetailPageDataModel的错误初始化.在构造函数完成其工作之后,变量Month的值更改为正确的值(在本例中为11).

FinanceItemViewControl是一个自定义用户控件.

<common:FinanceItemViewControl Grid.Column="2" Month="11"/>
Run Code Online (Sandbox Code Playgroud)

Month是一个依赖属性,如下面的代码所示:

public sealed partial class FinanceItemViewControl : UserControl
    {
...

        public static readonly DependencyProperty MonthProperty = DependencyProperty.Register
        (
             "Month",
             typeof(int),
             typeof(FinanceItemViewControl),
             new PropertyMetadata(
             0, new PropertyChangedCallback(MonthProperty_Changed))
        );

        public int Month
        {
            get { return (int)GetValue(MonthProperty); }
            set { SetValue(MonthProperty, value); }
        }
        #endregion

        private static void MonthProperty_Changed(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            //TODO: trigger data reload
        }

        public FinanceItemViewControl()
        {
            this.InitializeComponent();
...

            Debug.WriteLine("Constructor: " + Month);

            detailPageDataModel = new ExpenseDetailPageDataModel(Month);
...
        }
Run Code Online (Sandbox Code Playgroud)

c# xaml microsoft-metro windows-runtime winrt-xaml

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

在Windows 8 gridview中绑定到ObservableCollection中的更改对象

我有一个gridview:

      <GridView xmlns:controls="using:Windows.UI.Xaml.Controls">
        <GridView.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <Image Source="{Binding Image}"></Image>
                    <Grid Height="50" Width="50" Background="{Binding Color}"></Grid>
                    <TextBlock FontSize="25" TextWrapping="Wrap" Text="{Binding Name}" Margin="10,10,0,0"/>
                </Grid>
            </DataTemplate>
        </GridView.ItemTemplate>
    </GridView>
Run Code Online (Sandbox Code Playgroud)

这是一个可观察的收集:

   ObservableCollection<KeyItem> Keys = new ObservableCollection<KeyItem>();

   Keys.Add(new KeyItem { Name = "jfkdjkfd" });
   Keys.Add(new KeyItem { Name = "jfkdjkfd" });

   myView.ItemsSource = Keys;
Run Code Online (Sandbox Code Playgroud)

关键项是这样的:

public class KeyItem
{
    public string Name { get; set; }
    public ImageSource Image { get; private set; }
    public Brush Color
    {
        get;
        set;
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我在将颜色分配给itemssource之前设置颜色,这可以正常工作.

但我希望能够在分配KeyItem之后以编程方式更改颜色属性,并让Binding更改颜色.但是在这个配置中,这不起作用.

什么是让这个工作的最佳方法?

windows-8 windows-runtime winrt-xaml windows-store-apps

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

如何在Windows应用商店应用中保存ObservableCollection?

我正在基于Split App模板创建Windows应用商店应用.从SampleDataSource保存数据以供以后使用的最佳方法是什么?

我试过了:

Windows.Storage.ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;
roamingSettings.Values["Data"] = AllGroups;
Run Code Online (Sandbox Code Playgroud)

它抛出异常:'不支持此类型的数据'.

c# windows windows-8 windows-runtime

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

在windwos8中创建文件夹访问被拒绝

我使用下面的代码在应用程序安装的文件夹中创建文件夹,但我alwasy接收访问被拒绝的异常.

StorageFolder appFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
        if (!await CheckIfFolderExist(appDataFolderName))
        {                
            StorageFolder appDataFolder = await appFolder.CreateFolderAsync(appDataFolderName);
            StorageFolder userFolder = await appDataFolder.CreateFolderAsync(userFolderName);
            StorageFolder contactFolder = await appDataFolder.CreateFolderAsync(contactFolderName);
        }
        else
        {
            StorageFolder appDataFolder = await appFolder.GetFolderAsync(appDataFolderName);
            if (!await CheckIfSubFolderExis(appDataFolderName, userFolderName))
            {
                await appDataFolder.CreateFolderAsync(userFolderName);
            }
            if (!await CheckIfSubFolderExis(appDataFolderName, contactFolderName))
            {
                await appDataFolder.CreateFolderAsync(contactFolderName);
            }
        }

 // Check if the app folder exists
    private async Task<bool> CheckIfFolderExist(string folderName )
    {
        bool folderExist = false;
        try
        {
            StorageFolder appFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
            StorageFolder appDataFolder = await appFolder.GetFolderAsync(folderName);                
            folderExist = …
Run Code Online (Sandbox Code Playgroud)

c# io local-storage windows-8 windows-runtime

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

在后台任务中查找辅助磁贴失败,代码为1

我想通过后台任务更新我的辅助磁贴.我的问题是,迭代所有固定的瓷砖SecondaryTile.FindAllAsync();失败并退出我的背景任务代码1.

我不知道,为什么不可能这样做,为什么我没有任何例外以及为什么这在主应用程序中有效.这可能是一个记忆问题吗?

我的代码看起来像这样:

public sealed class SecondaryTileUpdater : IBackgroundTask
{
    public async void Run(IBackgroundTaskInstance taskInstance)
    {
        var list = await SecondaryTile.FindAllAsync(); // Here it fails :(
        foreach (SecondaryTile liveTile in list)
        {
            // Update Secondary Tiles
            // (...)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

The program '[5644] backgroundTaskHost.exe: Managed (v4.0.30319)' has exited with code 1 (0x1).
Run Code Online (Sandbox Code Playgroud)

任何想法,可能是什么原因?感谢您的任何帮助!

c# background windows-8 windows-runtime windows-store-apps

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

Windows 8商店应用程序开发没有触摸屏

我已经开始为一些工作项目进行Windows 8 Store应用程序开发,但我家里没有自己的触摸屏设备.如果我写个人应用程序提交到商店,我必须使用自己的硬件,因为我不能将工作计算机用于个人项目.我担心的是进入我向商店提交应用程序的情况,然后让触摸屏用户描述我无法在非触摸屏设备上复制的问题.

在使用触摸而不是仅使用鼠标时,是否存在在Windows 8商店应用中表现不同的任何功能或功能或交互?如果我没有触摸屏,是否有任何情况我可能会遇到无法重现或解决用户问题的问题?

windows-8 windows-runtime winjs winrt-xaml windows-store-apps

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