locked
Can Someone Please Help Me Create a Blog Reader App For My Blog?

    Question

  • Hi ! I am trying to create a blog reader app by using RSS feed for my blog. I found this tutorial on MSDN here Create a Blog Reader using C# and XAML

    But the problem is, it says some parts will not work with VS 2013. I even tried to follow each step of the tutorial but get stuck with some "navigation parameter" type-casted to a class. I couldn't understand what do I replace that with as it was never declared earlier somewhere. Can someone help me with the code? Please, I will be very thankful.

    I am using VS 2013 Community update 4 and Windows 8.1

    Monday, March 23, 2015 12:50 PM

Answers

All replies

  • Can you please post some code to explain what your problem is?
    Monday, March 23, 2015 12:55 PM
  • Here is the code and the error i am facing. I tried my best to do other changes like styles for buttons, textblocks etc that are new in 8.1

    protected override string DetermineVisualState(ApplicationViewState viewState)
            {
                // Update the back button's enabled state when the view state changes
                var logicalPageBack = this.UsingLogicalPageNavigation(viewState) && this.itemListView.SelectedItem != null;
                var physicalPageBack = this.Frame != null && this.Frame.CanGoBack;
                this.DefaultViewModel["CanGoBack"] = logicalPageBack || physicalPageBack;
    
                // Determine visual states for landscape layouts based not on the view state, but
                // on the width of the window.  This page has one layout that is appropriate for
                // 1366 virtual pixels or wider, and another for narrower displays or when a snapped
                // application reduces the horizontal space available to less than 1366.
                if (viewState == ApplicationViewState.Filled ||
                    viewState == ApplicationViewState.FullScreenLandscape)
                {
                    var windowWidth = Window.Current.Bounds.Width;
                    if (windowWidth >= 1366) return "FullScreenLandscapeOrWide";
                    return "FilledOrNarrow";
                }
    
                // When in portrait or snapped start with the default visual state name, then add a
                // suffix when viewing details instead of the list
                var defaultStateName = DetermineVisualState(viewState);
                return logicalPageBack ? defaultStateName + "_Detail" : defaultStateName;
            }


    errors:

    Error 1 An object of the type "System.Object" cannot be applied to a property that expects the type "Windows.UI.Xaml.Data.IValueConverter".

    I am using it here

     <TextBlock Text="{Binding PubDate, Converter={StaticResource dateConverter}}" 

    //DateConverter.cs

    using System; using Windows.Globalization.DateTimeFormatting; using Windows.UI.Xaml.Data; namespace WindowsBlogReader { public class DateConverter : Windows.UI.Xaml.Data.IValueConverter { public object Convert(object value, Type targetType, object parameter, string culture) { if (value == null) throw new ArgumentNullException("value", "Value cannot be null."); if (!typeof(DateTime).Equals(value.GetType())) throw new ArgumentException("Value must be of type DateTime.", "value"); DateTime dt = (DateTime)value; if (parameter == null) { // Date "7/27/2011 9:30:59 AM" returns "7/27/2011" return DateTimeFormatter.ShortDate.Format(dt); } else if ((string)parameter == "day") { // Date "7/27/2011 9:30:59 AM" returns "27" DateTimeFormatter dateFormatter = new DateTimeFormatter("{day.integer(2)}"); return dateFormatter.Format(dt); } else if ((string)parameter == "month") { // Date "7/27/2011 9:30:59 AM" returns "JUL" DateTimeFormatter dateFormatter = new DateTimeFormatter("{month.abbreviated(3)}"); return dateFormatter.Format(dt).ToUpper(); } else if ((string)parameter == "year") { // Date "7/27/2011 9:30:59 AM" returns "2011" DateTimeFormatter dateFormatter = new DateTimeFormatter("{year.full}"); return dateFormatter.Format(dt); } else { // Requested format is unknown. Return in the original format. return dt.ToString(); } } public object ConvertBack(object value, Type targetType, object parameter, string culture) { string strValue = value as string; DateTime resultDateTime; if (DateTime.TryParse(strValue, out resultDateTime)) { return resultDateTime; } return Windows.UI.Xaml.DependencyProperty.UnsetValue; } } }


    Error 2 The name "DateConverter" does not exist in the namespace "using:WindowsBlogReader".

    (DateConverter.cs is a class, I really don't understand why this error comes, i have decalared a local resource in app.xaml for it)

    <Application.Resources>
           
            <ResourceDictionary>
                
                <local:DateConverter x:Key="dateConverter"></local:DateConverter>

    Error 3 'WindowsBlogReader.SplitPage.DetermineVisualState(Windows.UI.ViewManagement.ApplicationViewState)' is a new virtual member in sealed class 'WindowsBlogReader.SplitPage'

    Error 4 'WindowsBlogReader.SplitPage.DetermineVisualState(Windows.UI.ViewManagement.ApplicationViewState)': no suitable method found to override

    Here is the visual state code for my 1st Page : ItemsPage.xaml

    <VisualStateManager.VisualStateGroups>
    
                <!-- Visual states reflect the application's view state -->
                <VisualStateGroup x:Name="ApplicationViewStates">
                    <VisualState x:Name="FullScreenLandscape"/>
                    <VisualState x:Name="Filled"/>
    
                    <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                    <VisualState x:Name="FullScreenPortrait">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" 
                                                           Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" 
                                                        Value="{StaticResource NavigationBackButtonSmallStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" 
                                                           Storyboard.TargetProperty="Padding">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="96,136,86,56"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
    
                    <!--
                        The back button and title have different styles when snapped, 
                        and the list representation is substituted
                        for the grid displayed in all other view states
                    -->
                    <VisualState x:Name="Snapped">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" 
                                                           Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" 
                                                        Value="{StaticResource NavigationBackButtonSmallStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" 
                                                           Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" 
                                                        Value="{StaticResource HeaderTextBlockStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
    
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView"
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" 
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>

    Visual State code for SplitPage.xaml (2nd Page)

    <VisualStateManager.VisualStateGroups>
                <!-- Visual states reflect the application's view state -->
                <VisualStateGroup x:Name="ApplicationViewStates">
                    <VisualState x:Name="FullScreenLandscapeOrWide"/>
    
                    <!-- Filled uses a simpler list format in a narrower column -->
                    <VisualState x:Name="FilledOrNarrow">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="primaryColumn" Storyboard.TargetProperty="Width">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="420"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="ItemTemplate">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource NarrowListItemTemplate}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetail" Storyboard.TargetProperty="Padding">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="60,0,66,0"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
    
                    <!--
                        The page respects the narrower 100-pixel margin convention for portrait, and the page
                        initially hides details to show only the list of items
                    -->
                    <VisualState x:Name="FullScreenPortrait">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource NavigationBackButtonNormalStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetail" Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Padding">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="100,0,90,60"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
    
                    <!--
                        When an item is selected in portrait the details display requires more extensive changes:
                         * Hide the master list and the column is was in
                         * Move item details down a row to make room for the title
                         * Move the title directly above the details
                         * Adjust margins and padding for details
                     -->
                    <VisualState x:Name="FullScreenPortrait_Detail">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource NavigationBackButtonNormalStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="primaryColumn" Storyboard.TargetProperty="Width">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetail" Storyboard.TargetProperty="(Grid.Row)">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetail" Storyboard.TargetProperty="(Grid.RowSpan)">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="titlePanel" Storyboard.TargetProperty="(Grid.Column)">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetailGrid" Storyboard.TargetProperty="Margin">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="0,0,0,60"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetail" Storyboard.TargetProperty="Padding">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="100,0,90,0"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
    
                    <!--
                        The back button and title have different styles when snapped, and the page
                        initially hides details to show only the list of items
                    -->
                    <VisualState x:Name="Snapped">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource NavigationBackButtonSmallStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource HeaderTextBlockStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="primaryColumn" Storyboard.TargetProperty="Width">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="320"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetail" Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="ItemTemplate">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource NarrowListItemTemplate}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Padding">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="20,0,0,0"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
    
                    <!--
                        When snapped and an item is selected the details display requires more extensive changes:
                         * Hide the master list and the column is was in
                         * Move item details down a row to make room for the title
                         * Move the title directly above the details
                         * Adjust margins and padding for details
                         * Use a different font for title and subtitle
                         * Adjust margins below subtitle
                     -->
                    <VisualState x:Name="Snapped_Detail">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource NavigationBackButtonSmallStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource HeaderTextBlockStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="primaryColumn" Storyboard.TargetProperty="Width">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetail" Storyboard.TargetProperty="(Grid.Row)">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetail" Storyboard.TargetProperty="(Grid.RowSpan)">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="titlePanel" Storyboard.TargetProperty="(Grid.Column)">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                            </ObjectAnimationUsingKeyFrames>
                            <!--<ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetailTitlePanel" Storyboard.TargetProperty="(Grid.Row)">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                            </ObjectAnimationUsingKeyFrames>-->
                            <!--<ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetailTitlePanel" Storyboard.TargetProperty="(Grid.Column)">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                            </ObjectAnimationUsingKeyFrames>-->
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetail" Storyboard.TargetProperty="Padding">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="20,0,20,0"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemDetailGrid" Storyboard.TargetProperty="Margin">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="0,0,0,60"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemTitle" Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TitleTextBlockStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemTitle" Storyboard.TargetProperty="Margin">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                            </ObjectAnimationUsingKeyFrames>
                            <!--<ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemSubtitle" Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource CaptionTextStyle}"/>
                            </ObjectAnimationUsingKeyFrames>-->
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>

    and finally , a Basic Page(DetailPage.xaml)

    <VisualStateManager.VisualStateGroups>
    
                <!-- Visual states reflect the application's view state -->
                <VisualStateGroup x:Name="ApplicationViewStates">
                    <VisualState x:Name="FullScreenLandscape"/>
                    <VisualState x:Name="Filled"/>
    
                    <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                    <VisualState x:Name="FullScreenPortrait">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" 
                                                           Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" 
                                                        Value="{StaticResource  NavigationBackButtonNormalStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
    
                    <!-- The back button and title have different styles when snapped -->
                    <VisualState x:Name="Snapped">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" 
                                                           Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" 
                                                        Value="{StaticResource NavigationBackButtonSmallStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" 
                                                           Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" 
                                                        Value="{StaticResource NavigationBackButtonSmallStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
    
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="contentViewBorder" 
                                                           Storyboard.TargetProperty="Margin">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="20,5,20,20"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
    Tuesday, March 24, 2015 10:16 AM
  • Can u please upload the solution to e.g. onedrive ?
    Tuesday, March 24, 2015 10:48 AM
  • Sure!

    Here is the link http://1drv.ms/1bpXYDm

    Also include this line in app.xaml resources ( <local:FeedDataSource x:Key="feedDataSource"></local:FeedDataSource> )

    i forgot to include it

    Thanks!
    Tuesday, March 24, 2015 11:41 AM
  • Oh, this is a 'old' win 8.0 project using the layoutawarepage which is not longer included.
    Take a look here:
    The LayoutAwarePage causes apps to break

    or

    Windows 8 to Windows 8.1 Preview starting with the XAML templates

    If you have more questions, ask ;D

    Tuesday, March 24, 2015 6:07 PM