如何在MvvmCross Forms项目中使用MvxImageView?

时间:2018-02-13 16:59:40

标签: c# xamarin xamarin.forms xamarin.android mvvmcross

首先,我是xamarin的新手,所以我可能会错过一些明显的东西。 我试图在页面中添加MvxImageView对象。 我的FirstPage.xaml.cs:

using MvvmCross.Forms.Views;
using MvvmCross.Plugins.DownloadCache;
using MvvmCross.Plugins.File;

namespace TandTapp.Core.Pages
{
    public partial class FirstPage
    {
        public FirstPage()
        {
            InitializeComponent();
            MvxImageView imageView = new MvxImageView();
            imageView.ImageUri = @"http://dreamfoot.net/img/stadiums/3/1.png";
            imageView.ErrorImagePath = @"http://dreamfoot.net/img/stadiums/3/1.png";
            imageView.DefaultImagePath = @"http://dreamfoot.net/img/stadiums/3/1.png";
            layout.Children.Add(imageView);

        }
    }
}

FirstPage.xaml

<?xml version="1.0" encoding="utf-8"?>
<mvx:MvxContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                    xmlns:forms="using:Xamarin.Forms"
                    xmlns:mvx="clr-namespace:MvvmCross.Forms.Core;assembly=MvvmCross.Forms"
                    x:Class="TandTapp.Core.Pages.FirstPage" 
                    Title="First Page">
    <mvx:MvxContentPage.Padding Thickness="5, 0, 5, 95">
        <OnPlatform x:TypeArguments="Thickness">
            <On Platform="Android" Value="5, 0, 5, 0" />
            <On Platform="iOS" Value="5, 20, 5, 0" />
        </OnPlatform>
    </mvx:MvxContentPage.Padding>
    <mvx:MvxContentPage.ToolbarItems>
        <ToolbarItem Name="Menu1" Text="About" ClassId="About" Order="Primary" Command="{Binding ShowAboutPageCommand}" />
    </mvx:MvxContentPage.ToolbarItems>
    <StackLayout Spacing="10" Orientation="Vertical" x:Name="layout">
        <Label FontSize="24" Text="Enter your nickname in the box below" />
        <Entry Placeholder="Who are you?" TextColor="Red" Text="{Binding YourNickname}" />
        <Label FontSize="24" Text="{Binding Hello}" />
    </StackLayout>
</mvx:MvxContentPage>

但是我收到了以下错误:

[0:] mvx:Error:  3,09 No IMvxImageHelper registered - you must provide an image helper before you can use a MvxImageView
[0:] mvx:Error:  3,09 No IMvxImageHelper registered - you must provide an image helper before you can use a MvxImageView
An unhandled exception occured.

This answer说我必须安装MvvmCross File和DownloadCache插件才能解决问题。但我已经在核心和机器人项目上安装了这些插件。有什么建议吗?

0 个答案:

没有答案