Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

IValueConverter not found.

$
0
0

I cant get my converter to get accepted, and cant figure out what I'm doing wrong.... Have read all I could find, but the compiler wount accept the XAML.

Converter:

namespace CDMForms.Converters
{
    public class UpdateTimeConverter : IValueConverter
    {
        public UpdateTimeConverter()
        { }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            DateTime lastUpdateDateTime;
            lastUpdateDateTime = (DateTime)value;

            if (lastUpdateDateTime != DateTime.MinValue)
                return "Last updated " + lastUpdateDateTime.ToLastUpdatedTimeString();
            else
                return "";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

XAML:

  <ContentPage.Resources>
    <ResourceDictionary>
      <cnv:UpdateTimeConverter x:Key="UpdateTimeCnv" />
      <Style x:Key="LabelStyle" TargetType="Label">
        <Setter Property="TextColor" Value="Color.Black"/>
        <Setter Property="BackgroundColor" Value="Color.White"/>
      </Style>
      <Style x:Key="LabelStyleAlternate" TargetType="Label">
        <Setter Property="TextColor" Value="Color.White"/>
        <Setter Property="BackgroundColor" Value="Color.Gray"/>
      </Style>
    </ResourceDictionary>

  </ContentPage.Resources>

Error;
Xamarin.Forms.Xaml.XamlParseException: Position 8:8. Type UpdateTimeConverter not found in xmlns http://xamarin.com/schemas/2014/forms


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>