I have WPF listbox:
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
on them:
Splat.Locator.CurrentMutable.Register(typeof(MyView), typeof(IViewFor));
Then, you can write the ListBox simply as:
This line will automatically wire up a DataTemplate for you:
this.OneWayBind(ViewModel, vm => vm.DownloadManager.FileDownloads, v => v.FileDownloads.ItemsSource);