LocalizedStrings not recognized in VS2015 Universal Project

102 Views Asked by At

I'm trying to convert a WP8 projet to Universal Apps. I'experiecing a strange error regarding LocalizedStrings.

I use Multilingual App Toolkit to manage translations. I've updated to the latest version (4.0) which says it supports Universal apps.

The thing is it gives me this error in App.xaml: The name "LocalizedStrings" does not exist in the namespace "using:StayfilmUniversalApp".

And it is complaining on the MainPage.xaml too but not in other pages... In MainPage.xaml it says that The type LocalizedStrings was not found. underlined in color blue the whole DataTemplate block that has a component which uses LocalizedStrings, for eg.:

<DataTemplate x:Key="TIT_WhatsNew">
        <Grid Width="250" Height="52" Margin="0" HorizontalAlignment="Left">
            <Rectangle Fill="White" HorizontalAlignment="Left" Height="3" Margin="0" VerticalAlignment="Top" Width="250" />
            <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="{Binding LocalizedResources.WHATSNEW, Mode=OneWay, Source={StaticResource LocalizedStrings}}" VerticalAlignment="Center" FontSize="21.333" FontStretch="ExtraCondensed" FontFamily="/Assets/Fonts/Frontage-regular.otf#Frontage Regular" />
            <Rectangle Fill="White" HorizontalAlignment="Left" Height="3" Margin="0" VerticalAlignment="Bottom" Width="250" />
        </Grid>
    </DataTemplate>

here is my App.xaml:

<Application
x:Class="StayfilmUniversalApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:StayfilmUniversalApp"
RequestedTheme="Light">

<Application.Resources>
    <ResourceDictionary>
        <!--<local:LocalizedStrings x:Key="LocalizedStrings"/>-->
        <local:LocalizedStrings xmlns:local="using:StayfilmUniversalApp" x:Key="LocalizedStrings" />
        <Color x:Key="PhoneDisabledColor">#66FFFFFF</Color>
        <SolidColorBrush x:Key="PhoneDisabledBrush" Color="{StaticResource PhoneDisabledColor}" />
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Styles\PhoneStyles.xaml" />
        </ResourceDictionary.MergedDictionaries>
        <!-- Other resources if you have -->
    </ResourceDictionary>
</Application.Resources>

and My LocalizedStrings.cs:

using StayfilmUniversalApp.Resources;

namespace StayfilmUniversalApp
{
    /// <summary>
    /// Provides access to string resources.
    /// </summary>
    public class LocalizedStrings
    {
        private static AppResources _localizedResources = new AppResources();

        public AppResources LocalizedResources { get { return _localizedResources; } }
    }
}
1

There are 1 best solutions below

1
rickrvo On

The problem has nothing to do with LocalizedStrings.

I gave up trying to fix the page and decided to recreate it from scratch. Doing so, I found out there may be a VS bug behind and is showing different error. because when I added a DataTemplate (this one below) to a HubSection it gave me this error on the entire DataTemplate block: Cannot add instance of type 'Windows.UI.Xaml.Setter' to a collection of type 'Windows.UI.Xaml.SetterBaseCollection'.

<DataTemplate x:Key="YOTWDataTemplate">
        <ScrollViewer HorizontalAlignment="Left" VerticalAlignment="Top" BorderThickness="0" Height="548">
                <StackPanel x:Name="stackYOTW" Margin="0,0,0,100" HorizontalAlignment="Center" VerticalAlignment="Top" Width="420">
                    <TextBlock TextWrapping="Wrap" Foreground="White" FontFamily="Portable User Interface" Margin="12,0,0,0">
                        <Run Text="{Binding LocalizedResources.EveryWeek, Mode=OneWay, Source={StaticResource LocalizedStrings}}"/>
                        <Run FontWeight="Bold" Text="YES!"/>
                        <LineBreak/>
                        <Run Text="{Binding LocalizedResources.ChoosenByStayfilm, Mode=OneWay, Source={StaticResource LocalizedStrings}}"/>
                        <LineBreak/>
                        <Run Text="{Binding LocalizedResources.ForYouToWatch, Mode=OneWay, Source={StaticResource LocalizedStrings}}"/>
                    </TextBlock>
                    <ListBox x:Name="listYOTW" ItemsSource="{Binding listYesMovie}" Foreground="White" Background="{x:Null}" BorderBrush="{x:Null}" ScrollViewer.VerticalScrollBarVisibility="Disabled">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="12,20,0,0" Background="White" Width="420">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="64"/>
                                        <ColumnDefinition/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="64*"/>
                                        <RowDefinition Height="119*"/>
                                        <RowDefinition Height="50*"/>
                                    </Grid.RowDefinitions>
                                    <Image Margin="12" Source="{Binding user.photo}" VerticalAlignment="Center" Width="40" Height="40" HorizontalAlignment="Center" Stretch="Fill"/>
                                    <TextBlock x:Name="NAME" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" FontFamily="Segoe WP Semibold" Margin="0" Grid.Column="1" Foreground="#FFAF252B" Text="{Binding user.fullName}" FontSize="18.667"/>
                                    <TextBlock x:Name="TIME" HorizontalAlignment="Right" TextWrapping="Wrap" VerticalAlignment="Center" FontFamily="Segoe WP Light" Margin="0,0,14,0" Grid.Column="1" Foreground="#FF787878" Text="{Binding prettyPublicated}" FontSize="17.333" TextAlignment="Right"/>
                                    <Image Grid.ColumnSpan="2" Margin="0,0,0,59" Grid.RowSpan="2" Source="{Binding thumbnailUrl}" Stretch="UniformToFill" Grid.Row="1"/>
                                    <Grid x:Name="TituloFILM" Grid.ColumnSpan="2" Height="50" VerticalAlignment="Top" Grid.Row="1" Background="#CCAF252B">
                                        <TextBlock x:Name="TITLE" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding title}" VerticalAlignment="Center" Foreground="White" FontFamily="Segoe WP Light" FontSize="24" Margin="14,0,0,0"/>
                                    </Grid>
                                    <Grid x:Name="GridYES" Grid.ColumnSpan="2" HorizontalAlignment="Left" Grid.RowSpan="2" VerticalAlignment="Bottom" Width="80" Grid.Row="2" Height="30" Margin="14">
                                        <Canvas x:Name="iconYES" HorizontalAlignment="Right" Height="20" UseLayoutRounding="False" VerticalAlignment="Center" Width="46" Margin="0">
                                            <Canvas x:Name="Layer_1" Height="15.391" Canvas.Left="0.409" Canvas.Top="2.304" Width="45.182">
                                                <Path Data="F1M10.991,0L7.327,5.987 3.619,0 0,0 5.741,8.801 5.741,14.9 8.913,14.9 8.913,8.801 14.61,0z" Fill="#FF9AA7B2" Height="14.9" Canvas.Left="0" Canvas.Top="0.223" Width="14.61"/>
                                                <Path Data="F1M0,14.901L0,0 10.544,0 10.544,2.793 3.172,2.793 3.172,5.943 10.388,5.943 10.388,8.734 3.172,8.734 3.172,12.109 10.544,12.109 10.544,14.901z" Fill="#FF9AA7B2" Height="14.901" Canvas.Left="15.552" Canvas.Top="0.223" Width="10.544"/>
                                                <Path Data="F1M0,13.024L1.72,10.611C2.77,11.706 4.4,12.622 6.457,12.622 8.199,12.622 9.046,11.817 9.046,10.968 9.046,8.332 0.469,10.142 0.469,4.534 0.469,2.055 2.613,0 6.121,0 8.489,0 10.455,0.715 11.929,2.077L10.164,4.4C8.958,3.283 7.349,2.77 5.83,2.77 4.468,2.77 3.708,3.373 3.708,4.267 3.708,6.635 12.263,5.048 12.263,10.611 12.263,13.336 10.32,15.391 6.299,15.391 3.44,15.391 1.384,14.431 0,13.024" Fill="#FF9AA7B2" Height="15.391" Canvas.Left="27.575" Canvas.Top="0" Width="12.263"/>
                                                <Path Data="F1M0.537,10.053L0.067,0 3.485,0 3.039,10.053z M0,13.337C0,12.354 0.805,11.528 1.787,11.528 2.77,11.528 3.598,12.354 3.598,13.337 3.598,14.297 2.77,15.124 1.787,15.124 0.805,15.124 0,14.297 0,13.337" Fill="#FF9AA7B2" Height="15.124" Canvas.Left="41.584" Canvas.Top="0.223" Width="3.598"/>
                                            </Canvas>
                                        </Canvas>

                                        <TextBlock x:Name="N_YES" HorizontalAlignment="Right" TextWrapping="Wrap" VerticalAlignment="Center" FontFamily="Segoe WP Light" Margin="0,0,59,3" Foreground="#FF35424D" Text="{Binding likeCount}" FontSize="20" TextAlignment="Right"/>
                                    </Grid>
                                    <Grid x:Name="GridCOMENT" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Bottom" Width="70" Grid.Row="2" Height="30" Margin="14">
                                        <Canvas x:Name="iconCOMENT" HorizontalAlignment="Right" Height="26" UseLayoutRounding="False" VerticalAlignment="Center" Width="28" Margin="0,2,0,0">
                                            <Canvas x:Name="Layer_4" Height="22.194" Canvas.Left="2.697" Canvas.Top="1.903" Width="22.605">
                                                <Path Data="M23.106,0.5L0.5,0.5 0.5,16.001 6.216,16.001 3.852,22.694 13.176,16.001 23.106,16.001z" Height="24.028" Canvas.Left="-0.5" Stroke="#FF9BA8B3" Canvas.Top="-0.5" Width="23.605"/>
                                            </Canvas>
                                        </Canvas>

                                        <TextBlock x:Name="N_YES1" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" FontFamily="Segoe WP Light" Margin="0,-3,0,0" Foreground="#FF35424D" Text="{Binding commentCount}" FontSize="20" TextAlignment="Right"/>
                                    </Grid>
                                    <Grid x:Name="GridVIEW" Grid.ColumnSpan="2" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="70" Grid.Row="2" Height="30" Margin="14">

                                        <Canvas x:Name="iconVIEW" HorizontalAlignment="Right" Height="26" UseLayoutRounding="False" VerticalAlignment="Center" Width="36">
                                            <Canvas x:Name="Layer_2" Height="18" Canvas.Left="2.113" Canvas.Top="4" Width="31.145">
                                                <Path Data="M31.723,9.5C28.609,4.125 22.809,0.5 16.151,0.5 9.492,0.5 3.692,4.125 0.578,9.5 3.692,14.875 9.492,18.5 16.151,18.5 22.809,18.5 28.609,14.875 31.723,9.5z" Height="19" Canvas.Left="-0.578" Stroke="#FF9BA8B3" Canvas.Top="-0.5" Width="32.301"/>
                                                <Path Data="F1M9.409,4.705C9.409,7.303 7.303,9.41 4.704,9.41 2.106,9.41 0,7.303 0,4.705 0,2.107 2.106,0 4.704,0 7.303,0 9.409,2.107 9.409,4.705" Fill="#FF9BA8B3" Height="9.41" Canvas.Left="10.868" Canvas.Top="4.295" Width="9.409"/>
                                            </Canvas>
                                        </Canvas>

                                        <TextBlock x:Name="N_YES2" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" FontFamily="Segoe WP Light" Margin="0,-3,0,0" Foreground="#FF35424D" Text="{Binding viewCount}" FontSize="20" TextAlignment="Right"/>
                                    </Grid>
                                    <Button Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}" Margin="0,50,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="2" Grid.Row="1" Click="Button_Click" Style="{StaticResource ButtonStyle}">
                                        <Canvas x:Name="PLAY" HorizontalAlignment="Center" Height="102" UseLayoutRounding="False" VerticalAlignment="Center" Width="102">
                                            <Canvas x:Name="Layer_3" Height="96" Canvas.Left="2" Canvas.Top="2" Width="96" Margin="0" Background="{StaticResource TransparentBrush}">
                                                <Path Data="F1M0,0L29.333,16.936 0,33.871z" Fill="White" Height="33.871" Canvas.Left="38.26" Canvas.Top="30.998" Width="29.333" Stroke="#26000000"/>
                                                <Ellipse Height="98" Stroke="#26000000" StrokeThickness="5" Width="98" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                <Ellipse Height="96" Stroke="White" StrokeThickness="3" Width="96" HorizontalAlignment="Center" VerticalAlignment="Center" Canvas.Left="1" Canvas.Top="1"/>
                                            </Canvas>
                                        </Canvas>
                                    </Button>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <TextBlock x:Name="txt_NoConnection" Foreground="White" TextWrapping="Wrap" Text="{Binding LocalizedResources.NoConnection, Mode=OneWay, Source={StaticResource LocalizedStrings}}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,48,0,0" FontFamily="Segoe WP Light" Visibility="Collapsed"/>
                </StackPanel>
            </ScrollViewer>
        </DataTemplate>

and I say it is a VS bug because I found this: VS bug report