This question is locked. New answers and comments are not allowed.
I'm moving my first steps into Caliburn.Micro and I'm working with a Pivot control.
I created the conductors and the view models for each pivot page, and everything goes fine until i replace my ListBox with the RadDataBoundListBox.
Here's the exception that I got:
First-chance exception 'System.InvalidOperationException' in System.Windows.ni.dll
Can't convert type Caliburn.Micro.BindableCollection`1[System.String] to type System.Windows.Visibility.
and here's the full stack trace :
Now let's get to the code.
This is the OnInitialize method of the conductor:
where _byGenre is an instance of:
Finally, here's the XAML (SearchByGenreView.xaml):
(this one is the one that works fine)
(this is the one who gives the exception)
as you can see, all that I've changed is the ListBox, which I replaced with the RadDataBoundListBox.
What am I doing wrong?
I created the conductors and the view models for each pivot page, and everything goes fine until i replace my ListBox with the RadDataBoundListBox.
Here's the exception that I got:
First-chance exception 'System.InvalidOperationException' in System.Windows.ni.dll
Can't convert type Caliburn.Micro.BindableCollection`1[System.String] to type System.Windows.Visibility.
and here's the full stack trace :
System.Windows.ni.dll!MS.Internal.Data.DefaultValueConverter.Create(System.Type sourceType, System.Type targetType, bool targetToSource) UnknownSystem.Windows.ni.dll!MS.Internal.Data.DynamicValueConverter.EnsureConverter(System.Type sourceType = {System.RuntimeType}, System.Type targetType = {System.RuntimeType}) UnknownSystem.Windows.ni.dll!MS.Internal.Data.DynamicValueConverter.Convert(object value = Count = 4, System.Type targetType = {System.RuntimeType}, object parameter = null, System.Globalization.CultureInfo culture = {System.Globalization.CultureInfo}) UnknownSystem.Windows.ni.dll!System.Windows.Data.BindingExpression.ConvertToTarget(object value = Count = 4) UnknownSystem.Windows.ni.dll!System.Windows.Data.BindingExpression.GetValue(System.Windows.DependencyObject d, System.Windows.DependencyProperty dp) UnknownSystem.Windows.ni.dll!System.Windows.DependencyObject.SetValueInternal(System.Windows.DependencyProperty dp = {System.Windows.CoreDependencyProperty}, object value, bool allowReadOnlySet) UnknownSystem.Windows.ni.dll!System.Windows.Data.BindingOperations.SetBinding(System.Windows.DependencyObject target, System.Windows.DependencyProperty dp, System.Windows.Data.BindingBase binding) UnknownCaliburn.Micro.DLL!Caliburn.Micro.ConventionManager..cctor.AnonymousMethod__3(System.Type viewModelType = {System.RuntimeType}, string path = "Items", System.Reflection.PropertyInfo property = {System.Reflection.RuntimePropertyInfo}, System.Windows.FrameworkElement element = {Telerik.Windows.Controls.RadDataBoundListBox}, Caliburn.Micro.ElementConvention convention = {Caliburn.Micro.ElementConvention}, System.Windows.DependencyProperty bindableProperty = {System.Windows.CoreDependencyProperty}) UnknownCaliburn.Micro.DLL!Caliburn.Micro.ConventionManager.SetBindingWithoutBindingOverwrite(System.Type viewModelType = {System.RuntimeType}, string path = "Items", System.Reflection.PropertyInfo property = {System.Reflection.RuntimePropertyInfo}, System.Windows.FrameworkElement element = {Telerik.Windows.Controls.RadDataBoundListBox}, Caliburn.Micro.ElementConvention convention = {Caliburn.Micro.ElementConvention}, System.Windows.DependencyProperty bindableProperty = {System.Windows.CoreDependencyProperty}) UnknownCaliburn.Micro.DLL!Caliburn.Micro.ElementConvention..ctor.AnonymousMethod__0(System.Type viewModelType = {System.RuntimeType}, string path = "Items", System.Reflection.PropertyInfo property = {System.Reflection.RuntimePropertyInfo}, System.Windows.FrameworkElement element = {Telerik.Windows.Controls.RadDataBoundListBox}, Caliburn.Micro.ElementConvention convention = {Caliburn.Micro.ElementConvention}) UnknownCaliburn.Micro.DLL!Caliburn.Micro.ViewModelBinder..cctor.AnonymousMethod__6(System.Collections.Generic.IEnumerable<System.Windows.FrameworkElement> namedElements = Count = 3, System.Type viewModelType = {System.RuntimeType}) UnknownCaliburn.Micro.DLL!Caliburn.Micro.ViewModelBinder..cctor.AnonymousMethod__9(object viewModel = {MyNamespace.ViewModels.SearchByGenreViewModel}, System.Windows.DependencyObject view = {MyNamespace.Views.SearchByGenreView}, object context = null) UnknownCaliburn.Micro.DLL!Caliburn.Micro.View.OnModelChanged(System.Windows.DependencyObject targetLocation = {System.Windows.Controls.ContentControl}, System.Windows.DependencyPropertyChangedEventArgs args = {System.Windows.DependencyPropertyChangedEventArgs}) UnknownSystem.Windows.ni.dll!System.Windows.DependencyObject.RaisePropertyChangeNotifications(System.Windows.DependencyProperty dp = {System.Windows.CustomAttachedDependencyProperty}, object oldValue, object newValue) UnknownSystem.Windows.ni.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.DependencyProperty property, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, System.Windows.DependencyObject.ValueOperation operation) UnknownSystem.Windows.ni.dll!System.Windows.DependencyObject.RefreshExpression(System.Windows.DependencyProperty dp) UnknownSystem.Windows.ni.dll!System.Windows.Data.BindingExpression.SendDataToTarget() UnknownSystem.Windows.ni.dll!System.Windows.Data.BindingExpression.SourceAcquired() UnknownSystem.Windows.ni.dll!System.Windows.Data.BindingExpression.System.Windows.IDataContextChangedListener.OnDataContextChanged(object sender, System.Windows.DataContextChangedEventArgs e) UnknownSystem.Windows.ni.dll!System.Windows.Data.BindingExpression.DataContextChanged(object sender, System.Windows.DataContextChangedEventArgs e) UnknownSystem.Windows.ni.dll!System.Windows.FrameworkElement.OnDataContextChanged(System.Windows.DataContextChangedEventArgs e) UnknownSystem.Windows.ni.dll!System.Windows.FrameworkElement.OnTreeParentUpdated(System.Windows.DependencyObject newParent, bool bIsNewParentAlive) UnknownSystem.Windows.ni.dll!System.Windows.DependencyObject.UpdateTreeParent(MS.Internal.IManagedPeer oldParent = null, MS.Internal.IManagedPeer newParent = {System.Windows.Controls.ContentPresenter}, bool bIsNewParentAlive, bool keepReferenceToParent = true) UnknownSystem.Windows.ni.dll!MS.Internal.FrameworkCallbacks.ManagedPeerTreeUpdate(System.IntPtr oldParentElement, System.IntPtr parentElement, System.IntPtr childElement, byte bIsParentAlive, byte bKeepReferenceToParent, byte bCanCreateParent) Unknown[From native to managed] [From managed to native] System.Windows.ni.dll!MS.Internal.XcpImports.FrameworkElement_MeasureOverride(System.Windows.FrameworkElement element = {Microsoft.Phone.Controls.PivotItem}, System.Windows.Size availableSize) UnknownMicrosoft.Phone.ni.dll!Microsoft.Phone.Controls.PivotItem.MeasureOverride(System.Windows.Size availableSize) UnknownSystem.Windows.ni.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget, double inWidth, double inHeight, [From native to managed] [From managed to native] System.Windows.ni.dll!MS.Internal.XcpImports.UIElement_UpdateLayout(System.Windows.UIElement element = {Microsoft.Phone.Controls.Pivot}) UnknownMicrosoft.Phone.ni.dll!Microsoft.Phone.Controls.Pivot.OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) UnknownSystem.Windows.ni.dll!System.Windows.Controls.ItemsControl.OnItemCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) UnknownSystem.Windows.ni.dll!System.Windows.Controls.ItemCollection.NotifyCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) UnknownSystem.Windows.ni.dll!System.Windows.Controls.ItemCollection.System.Windows.Controls.ICollectionChangedListener.OnCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) UnknownSystem.Windows.ni.dll!System.Windows.Controls.WeakCollectionChangedListener.SourceCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) UnknownSystem.ni.dll!System.Collections.ObjectModel.ObservableCollection<Caliburn.Micro.IScreen>.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) UnknownCaliburn.Micro.DLL!Caliburn.Micro.BindableCollection<Caliburn.Micro.IScreen>.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e = {System.Collections.Specialized.NotifyCollectionChangedEventArgs}) UnknownSystem.ni.dll!System.Collections.ObjectModel.ObservableCollection<System.__Canon>.InsertItem(int index, System.__Canon item) UnknownCaliburn.Micro.DLL!Caliburn.Micro.BindableCollection<Caliburn.Micro.IScreen>.InsertItemBase(int index = 3, Caliburn.Micro.IScreen item = {MyNamespace.ViewModels.SearchByGenreViewModel}) UnknownCaliburn.Micro.DLL!Caliburn.Micro.BindableCollection<Caliburn.Micro.IScreen>.InsertItem.AnonymousMethod__4() UnknownCaliburn.Micro.DLL!Caliburn.Micro.Execute.OnUIThread(System.Action action = {System.Action}) UnknownCaliburn.Micro.DLL!Caliburn.Micro.BindableCollection<Caliburn.Micro.IScreen>.InsertItem(int index = 3, Caliburn.Micro.IScreen item = {MyNamespace.ViewModels.SearchByGenreViewModel}) Unknownmscorlib.ni.dll!System.Collections.ObjectModel.Collection<Caliburn.Micro.IScreen>.Add(Caliburn.Micro.IScreen item) UnknownMyProjectDLL!MyNamespace.ViewModels.SearchViewModel.OnInitialize() Riga 26 C#Caliburn.Micro.DLL!Caliburn.Micro.Screen.Caliburn.Micro.IActivate.Activate() UnknownCaliburn.Micro.DLL!Caliburn.Micro.FrameAdapter.OnNavigated(object sender = {System.Windows.Navigation.NavigationService}, System.Windows.Navigation.NavigationEventArgs e = {System.Windows.Navigation.NavigationEventArgs}) UnknownMicrosoft.Phone.ni.dll!System.Windows.Navigation.NavigationService.RaiseNavigated(object content = {MyNamespace.Views.SearchView}, System.Uri uri = {System.Uri}, System.Windows.Navigation.NavigationMode mode = New, bool isNavigationInitiator = true, Microsoft.Phone.Controls.IPhoneApplicationPage existingContentPage = {MyNamespace.Views.MainPage}, Microsoft.Phone.Controls.IPhoneApplicationPage newContentPage = {MyNamespace.Views.SearchView}) UnknownMicrosoft.Phone.ni.dll!System.Windows.Navigation.NavigationService.CompleteNavigation(System.Windows.DependencyObject content, System.Windows.Navigation.NavigationMode mode = New) UnknownMicrosoft.Phone.ni.dll!System.Windows.Navigation.NavigationService.ContentLoader_BeginLoad_Callback(System.IAsyncResult result) UnknownMicrosoft.Phone.ni.dll!System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(System.AsyncCallback userCallback = {System.AsyncCallback}, System.Windows.Navigation.PageResourceContentLoader.PageResourceContentLoaderAsyncResult result = {System.Windows.Navigation.PageResourceContentLoader.PageResourceContentLoaderAsyncResult}) UnknownMicrosoft.Phone.ni.dll!System.Windows.Navigation.PageResourceContentLoader.BeginLoad.AnonymousMethod__0(object args) Unknown[From native to managed] mscorlib.ni.dll!System.Delegate.DynamicInvokeImpl(object[] args) UnknownSystem.Windows.ni.dll!System.Windows.Threading.DispatcherOperation.Invoke() UnknownSystem.Windows.ni.dll!System.Windows.Threading.Dispatcher.Dispatch(System.Windows.Threading.DispatcherPriority priority) UnknownSystem.Windows.ni.dll!System.Windows.Threading.Dispatcher.OnInvoke(object context) UnknownSystem.Windows.ni.dll!System.Windows.Hosting.CallbackCookie.Invoke(object[] args) UnknownSystem.Windows.RuntimeHost.ni.dll!System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(System.IntPtr pHandle, int nParamCount, System.Windows.Hosting.NativeMethods.ScriptParam* pParams, System.Windows.Hosting.NativeMethods.ScriptParam* pResult = 0x0055fab4) UnknownNow let's get to the code.
This is the OnInitialize method of the conductor:
protected override void OnInitialize(){ base.OnInitialize(); Items.Add(_byGenre); ActivateItem(_byGenre);}public class SearchByGenreViewModel : Screen{ private ObservableCollection<string> _items; public ObservableCollection<string> Items { get { return _items; } set { _items = value; NotifyOfPropertyChange(() => Items); } } public SearchByGenreViewModel() { Items = new BindableCollection<string> { "action", "adventure", "animation", "comedy" }; DisplayName = "by genre"; }}(this one is the one that works fine)
<ListBox x:Name="Items"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate></ListBox><telerikPrimitives:RadDataBoundListBox x:Name="Items" Margin="12,3,12,0" Visibility="Visible"> <telerikPrimitives:RadDataBoundListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding}" /> </StackPanel> </DataTemplate> </telerikPrimitives:RadDataBoundListBox.ItemTemplate></telerikPrimitives:RadDataBoundListBox>What am I doing wrong?
