简体   繁体   English

从AppStudio定制我的应用程序W10模板

[英]Customizing My app W10 Template from AppStudio

Customizing My app W10 Template from AppStudio 从AppStudio定制我的应用程序W10模板

Hello everyone, I'm new to programming and I wanted to make a Windows App just for fun, so far it looks good, however. 大家好,我是编程新手,我想制作一个Windows App只是为了好玩,但到目前为止看起来还不错。 I have a problem (mostly because I don't know what I'm doing). 我有一个问题(主要是因为我不知道自己在做什么)。 But I want the RSS feed to open Edge instead of the feed view (second page after you click on a feed icon) I found the config file for the rss feed ( I called it news) but I don't know how to make it open a new window on edge . 但是我希望RSS feed打开Edge而不是feed视图(单击feed图标后的第二页),我找到了rss feed的配置文件(我称其为news),但是我不知道如何制作它在边缘打开一个新的窗口。 The code is located at: 该代码位于:

Sections\\NewsConfig.cs Sections \\ NewsConfig.cs

Update: This is the full original code: 更新:这是完整的原始代码:

using System;
using System.Collections.Generic;
using AppStudio.DataProviders;
using AppStudio.DataProviders.Core;
using AppStudio.DataProviders.Rss;
using AppStudio.Uwp.Actions;
using AppStudio.Uwp.Commands;
using AppStudio.Uwp.Navigation;
using MyWindows10App.Config;
using MyWindows10App.ViewModels;

namespace MyWindows10App.Sections
{
public class NewsConfig : SectionConfigBase<RssDataConfig, RssSchema>
{
    public override DataProviderBase<RssDataConfig, RssSchema> DataProvider
    {
        get
        {
            return new RssDataProvider();
        }
    }

    public override RssDataConfig Config
    {
        get
        {
            return new RssDataConfig
            {
                Url = new Uri("https://localhost:804514/feed")
            };
        }
    }

    public override NavigationInfo ListNavigationInfo
    {
        get 
        {
            return NavigationInfo.FromPage("NewsListPage");
        }
    }

    public override ListPageConfig<RssSchema> ListPage
    {
        get 
        {
            return new ListPageConfig<RssSchema>
            {
                Title = "News",

                LayoutBindings = (viewModel, item) =>
                {
                    viewModel.Title = item.Title.ToSafeString();
                    viewModel.SubTitle = item.Summary.ToSafeString();
                    viewModel.Description = item.Summary.ToSafeString();
                    viewModel.Image = item.ImageUrl.ToSafeString();
                },
                NavigationInfo = (item) =>
                {
                    return null;
                }
            };
        }
    }

    public override DetailPageConfig<RssSchema> DetailPage
    {
        get
        {
            var bindings = new List<Action<ItemViewModel, RssSchema>>();

            var actions = new List<ActionConfig<RssSchema>>
            {
            };

            return new DetailPageConfig<RssSchema>
            {
                Title = "News",
                LayoutBindings = bindings,
                Actions = actions
            };
        }
    }

    public override string PageTitle
    {
        get { return "News"; }
    }
}
}

Update 2: here is the XAML from the List page 更新2:这是列表页面中的XAML

<Page
x:Class="MyWindows10App.Views.NewsListPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:was_actions="using:AppStudio.Uwp.Actions"
xmlns:was_commands="using:AppStudio.Uwp.Commands"
xmlns:was_controls="using:AppStudio.Uwp.Controls"
xmlns:layouts="using:MyWindows10App.Layouts"
xmlns:list_layouts="using:MyWindows10App.Layouts.List"
xmlns:controls="using:MyWindows10App.Layouts.Controls"
xmlns:vm="using:MyWindows10App.ViewModels"
xmlns:triggers="using:MyWindows10App.Triggers"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
d:DataContext="{d:DesignData Source=/Assets/Design/DesignData.json, Type=vm:DesignViewModel, IsDesignTimeCreatable=true}"
mc:Ignorable="d">
<Grid Background="{StaticResource AppBackground}">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="15"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>
    <Grid Grid.Row="0" Grid.ColumnSpan="2" Background="{StaticResource AppBarBackground}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="48"/>
    <TextBlock Grid.Row="0" Grid.Column="0" Margin="{Binding ViewModel.PageTitleMargin}" Text="{Binding ViewModel.PageTitle}" Foreground="{StaticResource AppBarForeground}" FontSize="21" VerticalAlignment="Center" HorizontalAlignment="Left" TextTrimming="WordEllipsis" MaxLines="1"/>
    <was_actions:ActionsCommandBar 
        x:Name="appBar"
        ActionsSource="{Binding ViewModel.Actions}" Style="{StaticResource WasCommandBarStyle}"
        Foreground="{StaticResource AppBarForeground}"
        IsVisible="{Binding ViewModel.HasActions}"
        Background="{StaticResource AppBarBackground}"
        Grid.Row="{Binding ViewModel.AppBarRow}"
        Grid.Column="{Binding ViewModel.AppBarColumn}"
        Grid.ColumnSpan="{Binding ViewModel.AppBarColumnSpan}">
    </was_actions:ActionsCommandBar>
    <ProgressBar Grid.Row="1" Grid.ColumnSpan="2" Height="3" Margin="0,6,0,6" IsIndeterminate="True" Foreground="{StaticResource PageTitleForeground}" Visibility="{Binding ViewModel.IsBusy, Converter={StaticResource BoolToVisibilityConverter}, FallbackValue=Collapsed}"/>
    <was_controls:ErrorNotificationControl Grid.ColumnSpan="2" x:Uid="ListErrorNotificationControl" Grid.Row="2" ErrorVisibility="{Binding ViewModel.HasLoadDataErrors, Converter={StaticResource BoolToVisibilityConverter}}" ErrorColor="{StaticResource PageTitleForeground}" Margin="10,0,18,0"/>
    <list_layouts:ListBigHorizontalCardBox Grid.Row="3" Grid.ColumnSpan="2" DataContext="{Binding ViewModel}" ItemsSource="{Binding Items}" ItemClickCommand="{Binding ItemClickCommand}" OneRowModeEnabled="False" Margin="19,0,12,0" />
    <controls:DataUpdateInformationControl Grid.ColumnSpan="2" Grid.Row="4" LastUpdateDateTime="{Binding ViewModel.LastUpdated}" Color="{StaticResource PageTitleForeground}" Margin="8,4,8,4" HorizontalAlignment="Left" HasLocalData="{Binding ViewModel.HasLocalData}"/>
</Grid>
</Page>

In UWP apps, While performing navigating you can use URI scheme or recommend any app to use that URI to open with. 在UWP应用中,执行导航时,您可以使用URI方案或建议任何应用使用该URI进行打开。

You can use the http URI scheme to launch default web browser as follows 您可以使用http URI方案来启动默认的Web浏览器,如下所示

// The URI to launch
   var uriFeed = new Uri(@"http://www.myblogfeed.com");

   // Launch the URI
   var success = await Windows.System.Launcher.LaunchUriAsync(uriFeed);

when launching any URI, you can also pass in LaucherOptions obect, where you can specify the preferredApplication for URI to launch it. 启动任何URI时,还可以传入LaucherOptions对象,在其中可以指定URI的preferredApplication来启动它。 Here is the example from a msdn page . 这是msdn页面上的示例。

// Set the recommended app
var options = new Windows.System.LauncherOptions();
options.PreferredApplicationPackageFamilyName = "Contoso.URIApp_8wknc82po1e";
options.PreferredApplicationDisplayName = "Contoso URI Ap";

// Launch the URI and pass in the recommended app 
// in case the user has no apps installed to handle the URI
var success = await Windows.System.Launcher.LaunchUriAsync(uriContoso, options);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM