如何判断我的 RSS reader 是否因 RSS 提要错误或其他原因而无法正常工作?

How to tell if my RSS reader isn't working because of a bad RSS feed or because of something else?

我在显示来自 RSS Reader 的 XML 数据时遇到问题,我尝试了来自许多不同来源的许多不同 RSS 提要,但我无法显示任何内容。

我正在尝试获取俄罗斯新闻 RSS Feed,我也使用了 BBC News Feed,但我无法获取任何数据,我无法确定它是在 RSS Feed 端还是在我的结局(代码,或者来自 Go 方法的东西)。我使用了一些示例 RSS 提要代码,它在我的电脑上运行正常,所以我只是在不同的阅读器上尝试过,它甚至根本不会显示任何内容。

这是我的 NewsFeedPage (XAML):

 <Grid>
        <NavigationView x:Name="NavView"
                        ItemInvoked="NavView_ItemInvoked"
                        SelectionChanged="NavView_SelectionChanged"
                        Loaded="NavView_Loaded"
                        Canvas.ZIndex="0" Background="White" Margin="0,0,222,10" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <NavigationView.MenuItems>
                <NavigationViewItem x:Name="HomeNav" Content="Home" Tag="Home" Icon="Home"/>
                <NavigationViewItemSeparator Height="100"></NavigationViewItemSeparator>
                <NavigationViewItemHeader Content="Separate Pages"/>
                <NavigationViewItem x:Name="AttractionsNav" Content="Attractions" Tag="Attractions" Icon="World"/>
                <NavigationViewItem x:Name="PlacestoEatNav" Content="Places to Eat" Tag="PlacesToEat" Icon="Like"/>
                <NavigationViewItem x:Name="MapNav" Content="Map" Tag="Map" Icon="Map"/>
                <NavigationViewItem x:Name="PhotosNav" Content="Photos" Tag="Photos" Icon="Camera"/>
                <NavigationViewItem x:Name="NewsNav" Content="News" Tag="News" Icon="Globe"/>
                <NavigationViewItem x:Name="WeatherNav" Content="Weather" Tag="weather" Icon="CalendarWeek"/>
            </NavigationView.MenuItems>


            <Frame x:Name="ContentFrame" Margin="24,24,0,24" Width="1916" VerticalAlignment="Stretch">
                <Frame.ContentTransitions>
                    <TransitionCollection>
                        <NavigationThemeTransition/>
                    </TransitionCollection>
                </Frame.ContentTransitions>
            </Frame>

        </NavigationView>

        <Grid HorizontalAlignment="Stretch" Margin="348,0,0,0" VerticalAlignment="Stretch">
            <Grid.ColumnDefinitions>
                <ColumnDefinition MaxWidth="1000"/>
                <ColumnDefinition MinWidth="500"/>
            </Grid.ColumnDefinitions>

            <Grid Grid.Column="0" Padding="12,12,12,0" KeyDown="Go_KeyDown">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <TextBox Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Top" Foreground="Firebrick" Text="BBC News" FontSize="28" Background="White" IsReadOnly="True"/>
                <TextBox Grid.Row="1" Name="value" VerticalAlignment="Center" TextWrapping="Wrap" Text="Press ENTER key to see latest new stories below. Click on a blue web address to see story details on the right." IsReadOnly="True"/>

                <ScrollViewer Grid.Row="2" Margin="20" BorderThickness="0">
                    <ItemsControl Name="display">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Background="GhostWhite">
                                    <TextBlock FontSize="24" TextWrapping="Wrap" Text="{Binding Path=Title.Text}" Foreground="Firebrick" Margin="2,2,10,2"/>
                                    <TextBlock Text="{Binding Path=PublishedDate}" Foreground="Firebrick"/>
                                    <TextBlock Text="{Binding Path=Summary.Text}" TextWrapping="WrapWholeWords" Foreground="Black"/>
                                    <TextBlock x:Name="address" Tapped="Address_OnTapped" Text="{Binding Path=Links[0].Uri}" Foreground="Blue">
                                    </TextBlock>
                                    <TextBlock></TextBlock>
                                    <Rectangle x:Name="BorderBottom" Height="4" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Fill="DarkSalmon"/>
                                </StackPanel>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>


                    </ItemsControl>
                </ScrollViewer>

            </Grid>

            <Grid Grid.Column="1">
                <WebView x:Name="ArticleWebView"/>
            </Grid>

        </Grid>


    </Grid>
</Page>

这是我的 NewsFeed.cs 文件:

public sealed partial class NewsFeedPage : Page
    {
        public NewsFeedPage()
        {
            this.InitializeComponent();
        }

        public NewsFeed MyFeed = new NewsFeed();

        public string address = "http://feeds.bbci.co.uk/news/rss.xml";



        private void Address_OnTapped(object sender, TappedRoutedEventArgs e)
        {
            var tblk = sender as TextBlock;
            Uri websiteuri = new Uri(tblk.Text);
            ArticleWebView.Navigate(websiteuri);
        }

        private void Go_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            MyFeed.Go(ref display, address, e);
        }

        private void NavView_Loaded(object sender, RoutedEventArgs e)
        {

        }


        private void NavView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
        {
            if (args.IsSettingsInvoked)
            {
                Frame.Navigate(typeof(SettingsPage));
            }

这是我的NewsFeed.cs文件(支持class):

namespace SEMESTER_PROJECT
{
    public class NewsFeed
    {
        private async void Load(ItemsControl list, Uri uri)
        {
            SyndicationClient client = new SyndicationClient();

            SyndicationFeed feed = await client.RetrieveFeedAsync(uri);

            if (feed != null)
            {
                foreach (SyndicationItem item in feed.Items)
                {
                    list.Items.Add(item);
                }
            }
        }

        public void Go(ref ItemsControl list, string value, KeyRoutedEventArgs args)
        {
            if (args.Key == Windows.System.VirtualKey.CapitalLock)
            {
                try
                {
                    Load(list, new Uri(value));

                }
                catch
                {
                    Console.Write("Yeah it didn't work for some reason.");
                }
                list.Focus(FocusState.Keyboard);
            }
        }

    }

}

我试过使用不同的键来启动 Go 方法,但 Enter 键使 NavigationView 变大变小,而 Tab 键在 NavigationView 中的选项之间移动。我不太确定是不是关键问题,但我认为可能是这样。

如果您的意思是按Enter时无法获取任何数据,问题出在这里:

if (args.Key == Windows.System.VirtualKey.CapitalLock)

如果要调用Go方法,按回车进入Load方法代码块。您需要更改代码:

if (args.Key == Windows.System.VirtualKey.Enter)

I've tried doing different keys to start the Go method, but the Enter key makes the NavigationView bigger and smaller while the Tab key moves between the options in the NavigationView. I'm not quite sure if the key is the problem, but that's what I think it might be.

这是设计使然。如果当前页面没有焦点元素,它会自动找到下一个可焦点元素,并在您按 Enter 时使其成为焦点。您可以通过编程手动关注某个元素来解决此问题。

例如,您可以在页面加载时关注 ItemsControl

private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
    display.Focus(FocusState.Programmatic);
}