Bind data inside ListBox using code-behind in ReactiveUI

好久不见. 提交于 2019-12-01 08:25:18

Is there any way to bind Url textbox inside the listbox using code-behind?

Not at the moment. You can either use XAML bindings like you're doing now, or you can put your data templates inside UserControls.

A consolation to this somewhat more cumbersome approach, is that if you register your data template UserControls and implement IViewFor<TViewModel> on them:

Splat.Locator.CurrentMutable.Register(typeof(MyView), typeof(IViewFor<MyViewModel>));

Then, you can write the ListBox simply as:

<ListBox Name="FileDownloads" SelectionMode="Extended" />

This line will automatically wire up a DataTemplate for you:

this.OneWayBind(ViewModel, vm => vm.DownloadManager.FileDownloads, v => v.FileDownloads.ItemsSource);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!