What namespace and assembly should be used to declare the converter in a common project in Xamarin.
for this resource
<TabbedPage.Resources> <ResourceDictionary> <local:WidthConverter x:Key="widthConverter"/> </ResourceDictionary> </TabbedPage.Resources>
If I select WindowsPhone as the Startup Project, this ad works:
xmlns:local="clr-namespace:LeMagXam;assembly=LeMagXam.WinPhone"
If I choose Android as the Startup Project, this declaration will work:
xmlns:local="clr-namespace:LeMagXam;assembly=LeMagXam.Android"
Now, what should I use to make it work for MixedPlateform, I tried this, but without success:
xmlns:local="clr-namespace:LeMagXam;assembly=LeMagXam"
Thanks in advance.
EDIT is my complete code for a better understanding.
<?xml version="1.0" encoding="UTF-8"?> <TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="LeMagXam.View.HomePage" xmlns:local="clr-namespace:LeMagXam;assembly=LeMagXam" Title="LeMag" BackgroundImage="bg_light.png" ItemsSource="{Binding CategoriesList}" > <TabbedPage.Resources> <ResourceDictionary> <local:WidthConverter x:Key="widthConverter"/> </ResourceDictionary> </TabbedPage.Resources> <TabbedPage.ItemTemplate> <DataTemplate> <ContentPage Title="{Binding Name}"> <-- ... --> <Image Source="{Binding Category.ImageArticleTitle.Source}" HorizontalOptions="Start" WidthRequest="{Binding , Converter={StaticResource widthConverter}, ConverterParameter=150}" <-- ... --> </ContentPage> </DataTemplate> </TabbedPage.ItemTemplate> </TabbedPage>
WidthConverter.cs
namespace LeMagXam { public class WidthConverter : IValueConverter { #region IValueConverter implementation public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return (double)parameter * App.RatioWidth; } public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException (); } #endregion } }
source share