Global Resources problem in Xamarin projects

Today I spent a lot of time to understand why my style doesn’t work.

<Application xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             x:Class="myProject.App">
    <Application.Resources>
        <ResourceDictionary>
            <Style x:Key="WarmGreyLine" TargetType="BoxView">
                <Setter Property="HeightRequest" Value="1" />
                <Setter Property="HorizontalOptions" Value="Fill" />
                <Setter Property="Color" Value="#EEE9E5" />
                <Setter Property="Margin" Value="0,10,0,10" />
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>

I followed a video about it on Xamarin University. Everything was the same. They say you can copy your style from a ContentPage.Resources and page in the Application.Resources section

    <ContentPage.Resources>
        <ResourceDictionary>
            <Style x:Key="WarmGreyLine" TargetType="BoxView">
                <Setter Property="HeightRequest" Value="1" />
                <Setter Property="HorizontalOptions" Value="Fill" />
                <Setter Property="Color" Value="#EEE9E5" />
                <Setter Property="Margin" Value="0,10,0,10" />
            </Style>
        </ResourceDictionary>
    </ContentPage.Resources>

The XAML is correct but if you execute the code you receive an error like:

Inner Exception: Position 38:14. StaticResource not found for key WarmGreyLine Message: Exception has been thrown by the target of an invocation.

The Solution

The is a little thing in the video they forgot to say!

In the App.xaml.cs you have to call InitializeComponent();

namespace myInventories
{
    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();
        }
    }
} 

Happy coding!

Microsoft's new adaptive shell will help Windows 10 scale across PC, Mobile, and Xbox

The Windows Shell is essentially the Windows environment we all know and love. In layman's terms, it gives us access to system elements and objects necessary for running applications, and houses features such as the Taskbar, Start Menu, Desktop and more. Currently, the Windows Shell is different depending on the version of Windows 10 you're using. For example, Mobile is using a different Windows Shell than desktop; but Microsoft is working to change and streamline that.

windows-10-logo-intro

Microsoft is building an "adaptive shell" into Windows 10 that'll work across PCs and tablets, phones, HoloLens, and even Xbox. As it currently stands, the Windows Shell isn't a true universal element of Windows, unlike the OneCore subsystem and Universal Windows Apps. PCs and tablets share the same shell thanks to Continuum, but Mobile, HoloLens and Xbox have their own individual shells that are updated and maintained separately.

Over the next few Windows 10 releases however, Microsoft will be bringing each of these device categories under one Windows Shell, making for a true universal Windows 10 experience no matter what device you're using. Internally referred to as "Composable Shell" or "CSHELL", this new Windows Shell will be able to scale in real-time between all types of devices, similarly to how Continuum currently works between desktop mode and tablet mode, only this time it'll scale across Xbox and Mobile as well.

For our more techy readers, the Composable Shell is essentially a shell modularized into sub-components. The system can transition between each component if it is required, making for a much more flexible experience on devices like 2-in-1's or something that has multiple form-factors.

Microsoft’s Channel 9 introduces .Game, a new series focused on game development using .NET

Game-Host-Development-1031x580

Microsoft has introduced a new show to its Channel 9 video platform aimed at teaching and showing off Microsoft’s products and services. The new show is called .Game and aims to teach people how to develop games using .NET.

In this new series, viewers will be able to watch along and discover how game development works and how to do it themselves. The first episode of the show is already available and focuses on the basics with Unity, a popular game engine.

The above video introduces the .Game show. Stacey Haffner explains that the show will provide tips and tricks, as well as access to files on Github to make use of, in addition to resources and other tutorials that people may find helpful when it comes to game development.

Advertsing

125X125_06

Planet Xamarin

Planet Xamarin

Calendar

<<  July 2017  >>
MonTueWedThuFriSatSun
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

View posts in large calendar

Month List