我应该使用哪个命名空间和程序集在Xamarin中的共享项目中声明转换器.
对于这个资源
<TabbedPage.Resources>
<ResourceDictionary>
<local:WidthConverter x:Key="widthConverter"/>
</ResourceDictionary>
</TabbedPage.Resources>
Run Code Online (Sandbox Code Playgroud)
如果我选择windowsPhone作为启动项目这个声明工作:
xmlns:local="clr-namespace:LeMagXam;assembly=LeMagXam.WinPhone"
Run Code Online (Sandbox Code Playgroud)
如果我选择Android作为启动项目这个声明工作:
xmlns:local="clr-namespace:LeMagXam;assembly=LeMagXam.Android"
Run Code Online (Sandbox Code Playgroud)
现在我应该使用什么来使它适用于MixedPlateform,我试过这个但没有成功:
xmlns:local="clr-namespace:LeMagXam;assembly=LeMagXam"
Run Code Online (Sandbox Code Playgroud)
先感谢您.
编辑有我的完整代码,以便更好地理解
<?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>
Run Code Online (Sandbox Code Playgroud)
WidthConverter.cs
namespace LeMagXam
{
public class WidthConverter : IValueConverter
{
#region IValueConverter implementation
public object Convert (object value, Type targetType, object …Run Code Online (Sandbox Code Playgroud)