Reputation:
I have this C# code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading;
namespace City
{
public static class MS
{
public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
private static void NotifyStaticPropertyChanged(string propertyName)
{
if (StaticPropertyChanged != null)
StaticPropertyChanged(null, new PropertyChangedEventArgs(propertyName));
}
private static int timerSeconds;
public static int TimerSeconds
{
get { return timerSeconds; }
set { timerSeconds = value; NotifyStaticPropertyChanged("TimerSeconds"); }
}
}
}
and this XAML
<Frame xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="City.Test">
<Label x:Name="timer" Text="{Binding Source={x:Static local:MS.TimerSeconds}}" />
</Grid>
When I compile it gives me a compile error saying:
Error: Value cannot be null. Parameter name: clrNamespace (City)
Does anyone have any idea what may be causing this. When I commment out the Label line or when I change to Text="ABC"
the error goes away
Upvotes: 0
Views: 1679
Reputation: 653
You did not define your local
namespace. You should add namespace: xmlns:local="clr-namespace:City"
. Change your code to something like this:
<Frame xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:City"
x:Class="City.Test">
<Label x:Name="timer" Text="{Binding Source={x:Static local:MS.TimerSeconds}}" />
</Grid>
For more information read this article
Upvotes: 3