当我在 Debug模式下构建时,一切正常。在 Release 中构建时,我的 MvxListView 没有被填充。
这与链接器和 MvvmCross 执行反射魔法有关,因此链接器不知道将绑定(bind)链接到何处。
他们说有一个名为“LinkerPleaseInclude.cs”的文件可以帮助伪造当时引用的绑定(bind)。
不知何故我的 ListView 仍然没有被填充..请帮助我...
链接器请包含文件:
class LinkerPleaseInclude
{
public void Include(ICommand command)
{
command.CanExecuteChanged += (s, e) =>
{
if (command.CanExecute(null))
{
command.Execute(null);
}
};
}
public void Include(MvxListView listview)
{
listview.ItemsSource = new List<int>();
var itemsSource = listview.ItemsSource;
}
public void Include(AnimalSearchViewModel viewmodel)
{
viewmodel.FilteredAnimals = new List<AnimalListInfoViewModel>();
}
}
AnimalSearchViewModel
public class AnimalSearchViewModel : ViewModelBase
{
private string searchString;
private MvxCommand<AnimalListInfoViewModel> itemSelectedCommand;
private readonly IUserDialogs userDialogs;
private readonly IAnimalsStorage animalsStorage;
private readonly IMapper mapper;
private readonly IDebug logger;
public IEnumerable<Animal> Animals { get; set; }
public IList<AnimalListInfoViewModel> FilteredAnimals { get; set; }
public string SearchString
{
get
{
return this.searchString;
}
set
{
this.FindResults(value);
}
}
public IMvxCommand ItemSelectedCommand
{
get
{
this.itemSelectedCommand = this.itemSelectedCommand ?? new MvxCommand<AnimalListInfoViewModel>(this.DoSelectItem);
return this.itemSelectedCommand;
}
}
public AnimalSearchViewModel(
IMvxMessenger messenger,
IUserDialogs dialogs,
IAnimalsStorage animalsStorage,
IMapper mapper,
IDebug logger)
: base(messenger, "Dierkaart")
{
this.userDialogs = dialogs;
this.animalsStorage = animalsStorage;
this.mapper = mapper;
this.logger = logger;
}
public void DoSelectItem(AnimalListInfoViewModel item)
{
this.ShowViewModel<AnimalListInfoViewModel>(new { id = item.Id });
this.logger.LogInfo(DebugTag.Core, "Key: " + item.Key + " Value: " + item);
}
protected override async void InitFromBundle(IMvxBundle parameters)
{
this.Animals = await this.animalsStorage.GetAnimalsAsync();
base.InitFromBundle(parameters);
}
private void FindResults(string keyword)
{
this.searchString = keyword;
if (this.searchString.Length >= 3)
{
var filteredAnimals = this.Animals.Where(i =>
{
// TODO: Get real displayvalue
var displayValue = i.Key;
return displayValue.IndexOf(this.searchString, StringComparison.OrdinalIgnoreCase) != -1;
}).ToArray();
this.FilteredAnimals = this.mapper.Map<List<AnimalListInfoViewModel>>(filteredAnimals);
}
else
{
this.FilteredAnimals = new List<AnimalListInfoViewModel>();
}
}
}
布局文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="?android:attr/actionBarSize"
android:fitsSystemWindows="true">
<EditText
android:id="@+id/search"
android:layout_width="fill_parent"
android:layout_height="@dimen/md_list_single_line_with_avatar_item_height"
android:paddingLeft="@dimen/md_list_item_horizontal_edges_padding"
android:paddingRight="@dimen/md_list_item_horizontal_edges_padding"
android:layout_alignParentTop="true"
android:drawableLeft="@android:drawable/ic_menu_search"
android:inputType="number"
android:singleLine="true"
android:hint="Type om te zoeken..."
local:MvxBind="Text SearchString"/>
<Mvx.MvxListView
android:id="@+id/select_list"
android:scrollbars="vertical"
android:layout_below="@id/search"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
local:MvxBind="ItemsSource FilteredAnimals; ItemClick ItemSelectedCommand"/>
</RelativeLayout>
我想 ItemsSource FilteredAnimals 将被填充,但在 Release模式下它不起作用。请帮助我。
最佳答案
我相信这个问题与您的 MvxListView 没有直接关系,而是与您的 EditText 中的文本更改有关。如果输入的值未返回到您的 ViewModel,它将不会触发 FindResult(string keyword) 并更新您的列表 FilteredAnimals。
您可以将 AfterTextChanged 事件添加到您的 LinkerPleaseInclude 以防止链接器将其删除。
public class LinkerPleaseInclude
{
public void Include(TextView text)
{
text.AfterTextChanged += (sender, args) => text.Text = "" + text.Text;
text.Hint = "" + text.Hint;
}
}
关于c# - MVVMCross Release 构建不工作(LinkerPleaseInclude Listview),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40738181/
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳
关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭8年前。Improvethisquestion在首页我有:汽车:VolvoSaabMercedesAudistatic_pages_spec.rb中的测试代码:it"shouldhavetherightselect"dovisithome_pathit{shouldhave_select('cars',:options=>['volvo','saab','mercedes','audi'])}end响应是rspec./spec/request
在Rails4.0.2中,我使用s3_direct_upload和aws-sdkgems直接为s3存储桶上传文件。在开发环境中它工作正常,但在生产环境中它会抛出如下错误,ActionView::Template::Error(noimplicitconversionofnilintoString)在View中,create_cv_url,:id=>"s3_uploader",:key=>"cv_uploads/{unique_id}/${filename}",:key_starts_with=>"cv_uploads/",:callback_param=>"cv[direct_uplo
如何在ruby中调用C#dll? 最佳答案 我能想到几种可能性:为您的DLL编写(或找人编写)一个COM包装器,如果它还没有,则使用Ruby的WIN32OLE库来调用它;看看RubyCLR,其中一位作者是JohnLam,他继续在Microsoft从事IronRuby方面的工作。(估计不会再维护了,可能不支持.Net2.0以上的版本);正如其他地方已经提到的,看看使用IronRuby,如果这是您的技术选择。有一个主题是here.请注意,最后一篇文章实际上来自JohnLam(看起来像是2009年3月),他似乎很自在地断言RubyCL
我正在尝试在Ruby中复制Convert.ToBase64String()行为。这是我的C#代码:varsha1=newSHA1CryptoServiceProvider();varpasswordBytes=Encoding.UTF8.GetBytes("password");varpasswordHash=sha1.ComputeHash(passwordBytes);returnConvert.ToBase64String(passwordHash);//returns"W6ph5Mm5Pz8GgiULbPgzG37mj9g="当我在Ruby中尝试同样的事情时,我得到了相同sha
使用Ruby1.9.2运行IDE提示说需要gemruby-debug-base19x并提供安装它。但是,在尝试安装它时会显示消息Failedtoinstallgems.Followinggemswerenotinstalled:C:/ProgramFiles(x86)/JetBrains/RubyMine3.2.4/rb/gems/ruby-debug-base19x-0.11.30.pre2.gem:Errorinstallingruby-debug-base19x-0.11.30.pre2.gem:The'linecache19'nativegemrequiresinstall
在编写Ruby(客户端脚本)时,我看到了三种构建更长字符串的方法,包括行尾,所有这些对我来说“闻起来”有点难看。有没有更干净、更好的方法?变量递增。ifrender_quote?quote="NowthatthereistheTec-9,acrappyspraygunfromSouthMiami."quote+="ThisgunisadvertisedasthemostpopularguninAmericancrime.Doyoubelievethatshit?"quote+="Itactuallysaysthatinthelittlebookthatcomeswithit:themo
C#实现简易绘图工具一.引言实验目的:通过制作窗体应用程序(C#画图软件),熟悉基本的窗体设计过程以及控件设计,事件处理等,熟悉使用C#的winform窗体进行绘图的基本步骤,对于面向对象编程有更加深刻的体会.Tutorial任务设计一个具有基本功能的画图软件**·包括简单的新建文件,保存,重新绘图等功能**·实现一些基本图形的绘制,包括铅笔和基本形状等,学习橡皮工具的创建**·设计一个合理舒适的UI界面**注明:你可能需要先了解一些关于winform窗体应用程序绘图的基本知识,以及关于GDI+类和结构的知识二.实验环境Windows系统下的visualstudio2017C#窗体应用程序三.