标签: windows-runtime

调用等待GetFileAsync()永远不会返回,应用程序在WinRT应用程序中挂起

我试图在应用程序启动时加载和读取设置文件,大约90%的时间,await GetFileAsync("filename.xml");永远不会返回,因此,挂起应用程序.

大约四分之一的时间,如果我单步执行代码,它实际上将返回并读取文件.

这是代码的一个非常简化的版本:

App.xaml.cs:

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
    FileLoader.Load().Wait();

    // File-load dependent stuff
}
Run Code Online (Sandbox Code Playgroud)

FileLoader.cs:

public async static Task Load()
{
    StorageFolder folder = ApplicationData.Current.LocalFolder;
    StorageFile file;
    bool fileExists = true;

    try
    {
        // The following line (often) never returns
        file = await folder.GetFileAsync("filename.xml");
    {
    catch
    {
        fileExists = false;
    }

    // Do stuff with loaded file
}
Run Code Online (Sandbox Code Playgroud)

如果我在Visual Studio中观看"输出"窗口,经过一段时间的等待,我得到了 "The thread '<No Name>' (0x30c) has exited with code 0 (0x0)."

有没有人知道这里发生了什么?

c# file-io async-await windows-8 windows-runtime

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

在Win10 UWP应用程序中获取屏幕分辨率

由于UWP App在普通桌面系统上以窗口模式运行,因此获取屏幕分辨率的"旧"方式将不再适用.

旧的分辨率与Window.Current.Bounds当时想显示英寸

是否有另一种方法来获得(主要)显示器的分辨率?

c# xaml windows-runtime windows-10 uwp

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

WinRT如何处理BitmapImage和Image内存

我是Windows Store应用程序的新手C#,我正在尝试了解图像内存的处理方式.我的应用很简单:

1)它使用Windows.UI.Xaml.Media.Imaging.BitmapImage对象从文件引用位图,然后将其用作Windows.UI.Xaml.Controls.Image对象的Source .在我的情况下,磁盘上的图像尺寸大于屏幕上显示的尺寸,因此系统会对其进行缩放.

我的问题是WinRT如何处理图像的内存?我使用了该vmmap工具,我在Mapped File部分看到我的图像文件有一个条目.我想这意味着这个文件的原始字节被完全加载到内存中.由于这是JPG,因此必须将这些字节解码为像素字节.从我的测试看来,设置BitmapImage的UriSource实际上并不会导致任何处理,因为它需要0毫秒,而是有一些延迟加载正在进行.

所以问题是:哪个对象是未压缩的非缩放像素数据的支配者?在屏幕上绘制的缩放像素数据的支配者是什么对象?有没有工具可以轻松告诉我这个?在Java世界中,我使用Eclipse内存分析器工具.我尝试使用PerfView,但结果对我没有意义,似乎该工具用于分析性能.

更新:

在BUILD会议上,团队讨论了这个问题Windows Performance Toolkit.我从未听过有人提到过PerfView,所以我相信WPT是分析内存和性能的最新最好的工具,这里有一个链接:

http://msdn.microsoft.com/en-us/performance/cc825801.aspx

clr memory-management windows-8 windows-runtime windows-store-apps

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

Windows 8,C++和Metro GUI示例?

所以我看看这个Windows构建主题演讲 (Windows构建主题演讲1:42:56)我只是不明白 - 我可以用什么来创建能够从我的C++代码调用函数的C++和/或GUI语言的GUI?HTML,XAML还是什么?在哪里可以看到使用C++ for Windows 8 Metro应用程序执行markup call codecode create GUI示例的代码示例?

c++ windows user-interface windows-8 windows-runtime

24
推荐指数
3
解决办法
2万
查看次数

有没有办法编写一个可以在Windows 7和Vista上运行的WinRt(Metro)应用程序?

我们不能让我们的客户长时间无法在落叶松中升级到Windows 8.但是,我们的应用需要 "平板电脑"/"触摸"版本.

那么我们如何才能支持Windows 8上的Metro与单个代码库中的当前客户的联系呢?

当WPF出现之后,经过很多微软推出的"推动"并使其在Windows XP上运行之后 - 就像WinRT所讨论的那样.

(我不希望任何解决方案在XP上工作,因为XP支持正在减少.)

另请参阅:ARM版本的Windows 8只能运行Metro(WinRt)风格的应用程序吗?

windows-7 microsoft-metro windows-8 windows-runtime

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

Windows 8和LOB应用程序

为Windows 8构建业务线应用程序的推荐方法是什么?例如复杂的定制金融应用

它们显然不适合Metro风格,因此可能是一个普通的桌面应用程序

那么使用WPF的建议是什么?这有vNext吗?

我作为开发人员构建的应用程序类型是桌面风格的应用程序.它们不适合Metro风格.关于这种风格的app,我们没有听到太多关于它的内容.

因此,如果您要推出一个桌面应用程序以配合Windows 8的发布 - 那么首选的技术应用是什么.(我得到的印象是WPF正在出路)

Win RT中有什么可以利用的吗?

非常感谢

wpf windows-8 windows-runtime

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

如何在WinRT中的ItemContainerStyle中进行绑定?

我正在尝试将一个集合绑定到ItemsControl,将Canvas作为items面板,并将每个项目的Canvas.Left和Top绑定到项目对象上的属性.基本上我正在尝试重新创建我在博客上的这篇文章中描述的二维数据绑定,但这次是在WinRT而不是WPF.

由于ItemsControl将您的ItemTemplate内容包装在另一个UI元素(在WinRT的情况下为ContentPresenter)中,并且它是直接放置在items面板中的那些包装器/容器元素,因此必须在这些容器上设置Left和Top; 你不能只在DataTemplate中设置它们.在WPF中,使用ItemContainerStyle中的绑定很容易做到这一点,例如:

<ItemsControl.ItemContainerStyle>
    <Style>
        <Setter Property="Canvas.Left" Value="{Binding Path=X}"/>
        <Setter Property="Canvas.Top" Value="{Binding Path=Y}"/>
    </Style>
</ItemsControl.ItemContainerStyle>
Run Code Online (Sandbox Code Playgroud)

但是当我在WinRT/XAML项目中尝试同样的事情时,我什么也得不到.甚至没有绑定错误.如果我对一个值进行硬编码,它就会起作用; 但是如果我使用绑定,则该属性将保持其默认值(零),并且"输出"窗口中不显示任何绑定错误.

<ItemsControl.ItemContainerStyle>
    <Style TargetType="ContentPresenter">
        <!-- This works, so ItemContainerStyle does work in WinRT: -->
        <Setter Property="Canvas.Left" Value="200"/>
        <!-- But this silently fails, leaves Top as 0, and does not show
             any binding errors in the debugger's Output window: -->
        <Setter Property="Canvas.Top" Value="{Binding Y}"/>
    </Style>
</ItemsControl.ItemContainerStyle>
Run Code Online (Sandbox Code Playgroud)

我已经验证了ContentPresenters确实有正确的DataContext(即集合项,而不是集合本身或其他时髦的东西),所以你认为这些绑定可以正常工作.但他们似乎甚至没有得到评估.如果我在其他地方放置了一个错误的绑定,并运行调试版本,我会在调试器的Output窗口中看到绑定错误; 但是如果我在ItemContainerStyle中引用了一个无意义的属性,则不会显示绑定错误.

这是一个更完整的例子,(据我所知)应该可以在WPF中正常工作,但是在WinRT中,所有内容都保留在原点:

<ItemsControl ItemsSource="{Binding Tiles}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <Canvas/>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ItemsControl.ItemContainerStyle>
        <Style …
Run Code Online (Sandbox Code Playgroud)

binding itemscontrol itemcontainerstyle windows-runtime winrt-xaml

24
推荐指数
2
解决办法
8018
查看次数

MessageDialog ShowAsync在第二个对话框上抛出accessdenied异常

我试图在Windows 8中再次尝试/取消对话框.对话框第一次显示正常,但是再次单击尝试再次失败,我在调用ShowAsync时得到访问被拒绝的异常.我不知道为什么,但奇怪的是,有时代码工作正常,当我放置断点时我没有得到异常.这里真的很无能为力

这是代码.

    async void DismissedEventHandler(SplashScreen sender, object e)
    {
        dismissed = true;
        loadFeeds();
    }
    private async void loadFeeds()
    {
        await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
        {
            try
            {
                RSSDataSource rssDataSource = (RSSDataSource)App.Current.Resources["RSSDataSource"];
                if (rssDataSource != null)
                {
                    await rssDataSource.DownloadFeeds();
                    await rssDataSource.GetFeedsAsync();
                }

                AdDataSource ads = (AdDataSource)App.Current.Resources["AdDataSource"];

                if (ads != null)
                {
                    await ads.DownloadAds();
                }
                rootFrame.Navigate(typeof(HomePageView));

                Window.Current.Content = rootFrame;
            }
            catch
            {
                ShowError();
            }

        });
    }
    async void ShowError()
    {
        // There was likely a problem initializing
        MessageDialog msg = new …
Run Code Online (Sandbox Code Playgroud)

windows messagedialog windows-8 windows-runtime winrt-xaml

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

进度条与HttpClient

我有一个文件下载功能:

        HttpClientHandler aHandler = new HttpClientHandler();
        aHandler.ClientCertificateOptions = ClientCertificateOption.Automatic;
        HttpClient aClient = new HttpClient(aHandler);
        aClient.DefaultRequestHeaders.ExpectContinue = false;
        HttpResponseMessage response = await aClient.GetAsync(url);
        InMemoryRandomAccessStream randomAccessStream = new InMemoryRandomAccessStream();

        // To save downloaded image to local storage
        var imageFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(
        filename, CreationCollisionOption.ReplaceExisting);
        var fs = await imageFile.OpenAsync(FileAccessMode.ReadWrite);
        DataWriter writer = new DataWriter(fs.GetOutputStreamAt(0));

        writer.WriteBytes(await response.Content.ReadAsByteArrayAsync());

        await writer.StoreAsync();
        //current.image.SetSource(randomAccessStream);
        writer.DetachStream();
        await fs.FlushAsync();
Run Code Online (Sandbox Code Playgroud)

我怎样才能实现进度条功能?也许到目前为止我可以写出写入的字节数?或者其他的东西?

PS我无法使用DownloadOperation(后台传输),因为来自服务器的数据请求证书 - 并且DownloadOperations中不存在此功能.

c# download windows-8 windows-runtime windows-8.1

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

Windows Phone 8.1中的ListView在滚动浏览长列表时抖动(XAML)

我在Windows Phone 8.1应用程序中滚动浏览ListViews时遇到问题.短列表滚动得很好,滚动顺畅但是很快虚拟化就会在整个ListView"摆动"中向左轻微踢,但是明显足以令人讨厌.

我已经尝试删除所有过渡到没有效果,以及项目加载增加到没有成功.将项目面板设置为StackPanel(删除虚拟化)可以解决问题,但不是更可取.

我的列表视图绑定到BasicView模板附带的DefaultViewModel中的属性.

我做错了什么以及导致我的ListViews出现这种行为的原因是什么?

XAML:

<ListView x:Name="searchResultsList" IsItemClickEnabled="True" ItemClick="ListView_ItemClick" ItemsSource="{Binding searchResults}">
   <ListView.ItemContainerStyle>
      <Style TargetType="ListViewItem">
          <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
          <Setter Property="Margin" Value="0,0,0,20" />
      </Style>
   </ListView.ItemContainerStyle>
   <ListView.ItemTemplate>
      <DataTemplate>
          <Grid>
             <Grid.ColumnDefinitions>
                <ColumnDefinition Width="80" />
                <ColumnDefinition Width="10" />
                <ColumnDefinition Width="*" />
             </Grid.ColumnDefinitions>

             <Border Width="80" Height="80">
                <Image Source="{Binding Image}" />
             </Border>

             <StackPanel Grid.Column="2">
                <TextBlock Text="{Binding PodcastTitle}" TextWrapping="WrapWholeWords" FontSize="{StaticResource TextStyleExtraLargeFontSize}" />
                <TextBlock Text="{Binding LastUpdated, Converter={StaticResource dateConverter}}" Style="{ThemeResource ListViewItemSubheaderTextBlockStyle}" />
                <TextBlock Text="{Binding PodcastArtist}" TextWrapping="WrapWholeWords" Style="{ThemeResource ListViewItemContentTextBlockStyle}" />
             </StackPanel>
           </Grid>
       </DataTemplate>
   </ListView.ItemTemplate>
 </ListView>
Run Code Online (Sandbox Code Playgroud)

c# xaml windows-runtime windows-phone-8.1

24
推荐指数
2
解决办法
6798
查看次数