"BindingExpression path error" using ItemsControl and VirtualizingStackPanel - silverlight

I'm using Silverlight on Windows Phone 7.
Is it normal to get loads of "BindingExpression path error" debug messages when using a VirtualizingStackPanel? I think it is happening because the visual items are temporarily unbound from the data items collection as they are recycled ...
I have an ItemsControl whose ItemsPanel's ItemsPanelTemplate is a VirtualizingStackPanel. It binds to a "Notes" ObservableCollection on my ViewModel.
<ItemsControl x:Name="ListView" ItemsSource="{Binding Notes}"
ItemTemplate="{StaticResource ListDataTemplate}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Template>
<ControlTemplate>
<ScrollViewer x:Name="ScrollViewer" Padding="{TemplateBinding Padding}">
<ItemsPresenter/>
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
</ItemsControl>
This is within a UserControl whose DataContext is set to a MainViewModel ViewModel.
The ListDataTemplate contains a Button, which itself contains some text, data-bound to a property of the items in the Notes ObservableCollection:
<DataTemplate x:Key="ListDataTemplate">
<Button>
<Grid>
<TextBlock TextWrapping="Wrap" Text="{Binding Title}">
</Grid>
</Button>
</DataTemplate>
When I run my program it all works fine - only a small number of items in my Notes collection are bound to at any one time. However I get lots of debug errors as I scroll up and down:
System.Windows.Data Error: BindingExpression path error: 'Title' property not found on 'EnWp7.ViewModels.MainViewModel' 'EnWp7.ViewModels.MainViewModel' (HashCode=119211466). BindingExpression: Path='Title' DataItem='EnWp7.ViewModels.MainViewModel' (HashCode=119211466); target element is 'System.Windows.Controls.TextBlock' (Name=''); target property is 'Text' (type 'System.String')..
System.Windows.Data Error: BindingExpression path error: 'Title' property not found on 'EnWp7.ViewModels.MainViewModel' 'EnWp7.ViewModels.MainViewModel' (HashCode=119211466). BindingExpression: Path='Title' DataItem='EnWp7.ViewModels.MainViewModel' (HashCode=119211466); target element is 'System.Windows.Controls.TextBlock' (Name=''); target property is 'Text' (type 'System.String')..
System.Windows.Data Error: BindingExpression path error: 'Title' property not found on 'EnWp7.ViewModels.MainViewModel' 'EnWp7.ViewModels.MainViewModel' (HashCode=119211466). BindingExpression: Path='Title' DataItem='EnWp7.ViewModels.MainViewModel' (HashCode=119211466); target element is 'System.Windows.Controls.TextBlock' (Name=''); target property is 'Text' (type 'System.String')..
System.Windows.Data Error: BindingExpression path error: 'Title' property not found on 'EnWp7.ViewModels.MainViewModel' 'EnWp7.ViewModels.MainViewModel' (HashCode=119211466). BindingExpression: Path='Title' DataItem='EnWp7.ViewModels.MainViewModel' (HashCode=119211466); target element is 'System.Windows.Controls.TextBlock' (Name=''); target property is 'Text' (type 'System.String')..
It is looking for the "Title" property on the main view model (whose Notes property is the ItemsSource) - I think this is normal - it is a transient situation as the visual items are unbound from items in the Notes collection in order to be recycled by assigning them to another item in the collection.
Has anyone else seen this? Am I right that it is normal?
If I create a dummy Title property on my MainViewModel and set a debug breakpoint then I see this stack trace. Note the "UnlinkContainerFromItem":
...!EnWp7.ViewModels.MainViewModel.Title.get() Line 54 C#
mscorlib.dll!System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo rtmi = {System.Reflection.RuntimeMethodInfo}, object obj = {EnWp7.ViewModels.MainViewModel}, System.Reflection.BindingFlags invokeAttr = Default, System.Reflection.Binder binder = null, object parameters = null, System.Globalization.CultureInfo culture = null, bool isBinderDefault = false, System.Reflection.Assembly caller = null, bool verifyAccess = true, ref System.Threading.StackCrawlMark stackMark = LookForMyCaller)
mscorlib.dll!System.Reflection.RuntimeMethodInfo.InternalInvoke(object obj = {EnWp7.ViewModels.MainViewModel}, System.Reflection.BindingFlags invokeAttr = Default, System.Reflection.Binder binder = null, object[] parameters = null, System.Globalization.CultureInfo culture = null, ref System.Threading.StackCrawlMark stackMark = LookForMyCaller) + 0x14e bytes
mscorlib.dll!System.Reflection.RuntimePropertyInfo.InternalGetValue(System.Reflection.PropertyInfo thisProperty = {System.Reflection.RuntimePropertyInfo}, object obj = {EnWp7.ViewModels.MainViewModel}, object[] index = null, ref System.Threading.StackCrawlMark stackMark = LookForMyCaller) + 0x4e bytes
mscorlib.dll!System.Reflection.RuntimePropertyInfo.GetValue(object obj = {EnWp7.ViewModels.MainViewModel}, object[] index = null) + 0x2 bytes
System.Windows.dll!System.Windows.CLRPropertyListener.Value.get() + 0x1b bytes
System.Windows.dll!System.Windows.PropertyAccessPathStep.ConnectToPropertyInSource() + 0x148 bytes
System.Windows.dll!System.Windows.PropertyAccessPathStep.ConnectToProperty() + 0x16 bytes
System.Windows.dll!System.Windows.PropertyAccessPathStep.ReConnect(object newSource = {EnWp7.ViewModels.MainViewModel}) + 0x13 bytes
System.Windows.dll!System.Windows.PropertyPathListener.ReConnect(object source = {EnWp7.ViewModels.MainViewModel}) + 0x10 bytes
System.Windows.dll!System.Windows.Data.BindingExpression.SourceAquired() + 0x11 bytes
System.Windows.dll!System.Windows.Data.BindingExpression.DataContextChanged(object o = {System.Windows.Controls.TextBlock}, System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x26 bytes
System.Windows.dll!System.Windows.FrameworkElement.OnDataContextChanged(System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x15 bytes
System.Windows.dll!System.Windows.FrameworkElement.OnAncestorDataContextChanged(System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x11 bytes
System.Windows.dll!System.Windows.FrameworkElement.NotifyDataContextChanged(System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x59 bytes
System.Windows.dll!System.Windows.FrameworkElement.OnAncestorDataContextChanged(System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x18 bytes
System.Windows.dll!System.Windows.FrameworkElement.NotifyDataContextChanged(System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x59 bytes
System.Windows.dll!System.Windows.FrameworkElement.OnAncestorDataContextChanged(System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x18 bytes
System.Windows.dll!System.Windows.FrameworkElement.NotifyDataContextChanged(System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x59 bytes
System.Windows.dll!System.Windows.FrameworkElement.OnAncestorDataContextChanged(System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x18 bytes
System.Windows.dll!System.Windows.FrameworkElement.NotifyDataContextChanged(System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x59 bytes
System.Windows.dll!System.Windows.FrameworkElement.OnAncestorDataContextChanged(System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x18 bytes
System.Windows.dll!System.Windows.FrameworkElement.NotifyDataContextChanged(System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x59 bytes
System.Windows.dll!System.Windows.FrameworkElement.OnAncestorDataContextChanged(System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x18 bytes
System.Windows.dll!System.Windows.FrameworkElement.NotifyDataContextChanged(System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x59 bytes
System.Windows.dll!System.Windows.FrameworkElement.OnAncestorDataContextChanged(System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x18 bytes
System.Windows.dll!System.Windows.FrameworkElement.NotifyDataContextChanged(System.Windows.DataContextChangedEventArgs e = {System.Windows.DataContextChangedEventArgs}) + 0x59 bytes
System.Windows.dll!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyProperty dp = {System.Windows.CoreDependencyProperty}) + 0x1d bytes
System.Windows.dll!System.Windows.DependencyObject.RaisePropertyChangeNotifications(System.Windows.DependencyProperty dp = {System.Windows.CoreDependencyProperty}, object newValue = {EnWp7.ViewModels.MainViewModel}, object oldValue = {EnWp7.Store.NoteLocal}) + 0x38 bytes
System.Windows.dll!System.Windows.DependencyObject.ClearValueInternal(System.Windows.DependencyProperty dp = {System.Windows.CoreDependencyProperty}) + 0x138 bytes
System.Windows.dll!System.Windows.DependencyObject.ClearValue(System.Windows.DependencyProperty dp = {System.Windows.CoreDependencyProperty}) + 0x7 bytes
System.Windows.dll!System.Windows.Controls.ItemContainerGenerator.UnlinkContainerFromItem(System.Windows.DependencyObject container = {System.Windows.Controls.ContentPresenter}, object item = {EnWp7.Store.NoteLocal}, bool isRecycling = true) + 0x1f bytes
System.Windows.dll!System.Windows.Controls.ItemContainerGenerator.Remove(System.Windows.Controls.Primitives.GeneratorPosition position = {System.Windows.Controls.Primitives.GeneratorPosition}, int count = 2, bool isRecycling = true) + 0x14a bytes
System.Windows.dll!System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IRecyclingItemContainerGenerator.Recycle(System.Windows.Controls.Primitives.GeneratorPosition position = {System.Windows.Controls.Primitives.GeneratorPosition}, int count = 2) + 0x9 bytes
System.Windows.dll!System.Windows.Controls.VirtualizingStackPanel.CleanupRange(int startIndex = 0, int count = 2) + 0x20 bytes
System.Windows.dll!System.Windows.Controls.VirtualizingStackPanel.CleanupContainers(System.Windows.Controls.ItemsControl itemsControl = {System.Windows.Controls.ItemsControl}) + 0x73 bytes
System.Windows.dll!System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(System.Windows.Size constraint = {System.Windows.Size}) + 0xe4 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget = 102509504, float inWidth = 480.0, float inHeight = 499.0, out float outWidth = 0.0, out float outHeight = 0.0) + 0x45 bytes
Thanks,
Damian

I think your assessment of the situation is correct, but it sounds like a bug in the way the VirtualizingStackPanel works. It's not affecting the execution or bindings of your application at the points where you need it, but raising exceptions is a relatively expensive operation and so it would make sense to update the appropriate DataContext accordingly when unlinking the containers.
I think the best place to raise it as a potential bug would be on the App Hub forums

I know this post is pretty old, but a solution without creating the dummy properties is making sure the DataContext of the items can only be of the type you expect.
I do this with the following converter on the root of the data template:
public class SpecificTypeConverter : IValueConverter
{
public string Type { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null || value.GetType().FullName == this.Type)
{
return value;
}
return DependencyProperty.UnsetValue;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Add a static resource like this:
<p:PhoneApplicationPage.Resources>
<converters:SpecificTypeConverter x:Key="MustBeItem" Type="My.Namespace.MyListItemViewModel" />
</p:PhoneApplicationPage.Resources>
And in the data template, use the converter:
<DataTemplate>
<StackPanel DataContext="{Binding Converter={StaticResource MustBeItem}}" >
<TextBlock Tekst="{Binding Path=Name}" />
</StackPanel>
</DataTemplate>
Now the Name property of the parent will never be checked.

Related

How can I bind RotateTransform.Angle value via a Converter?

I need to create a Converter that takes some value and returns another. This will be used to set the textblock RotateTransform.Angle value in XAML.
If I hard-code the value to a static number the textblock gets rotated successfully. But when it goes through the converter it does not get rotated.
Any insight would be appreciated.
Thanks.
Hard-coded value (works):
<TextBlock ...
<RotateTransform CenterX="0.5" CenterY="0.5">
<RotateTransform.Angle>
10
</RotateTransform.Angle>
</RotateTransform>
Going through a Converter (does not work):
<TextBlock ...
<RotateTransform CenterX="0.5" CenterY="0.5">
<RotateTransform.Angle>
<MultiBinding Converter="{StaticResource RelativeToAbsoluteRotationConverter}">
<Binding Path="RelativeAngle" />
</MultiBinding>
</RotateTransform.Angle>
</RotateTransform>
Converter class:
public class RelativeToAbsoluteRotationConverter: IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
// Add logic here... Function is hit, but no rotation ever takes place.
return 10; // irrelevant
}
// ...
Output window:
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property. Int32:'30' MultiBindingExpression:target element is 'RotateTransform' (HashCode=57454947); target property is 'Angle' (type 'Double')
The solution is to modify the object Convert() method and instead of returning an int (e.g. 10), we return a double value (e.g. 10d or 10.0).
return 10d; // This works

How to bind int to Visibility in WPF?

I have BudgetControlType Properties that has 1 .. 7 value
if(BudgetControlType ==1)
dataComboBox1.Visibility=Visibility.Visiblile;
dataComboBox2 to dataComboBox7 =Visibility.Hidden;
if(BudgetControlType ==2)
dataComboBox1.Visibility=Visibility.Visiblile;
dataComboBox2.Visibility=Visibility.Visiblile;
dataComboBox3 to dataComboBox7 =Visibility.Hidden;
and so on...
How to do this in xaml?
Here is another approach I have used in the past using WPFConverters.
<TabItem.Visibility>
<Binding Path="SomeObservableCollection.Count">
<Binding.Converter>
<converters:ConverterGroup>
<converters:ExpressionConverter Expression="{}{0} > 0" />
<BooleanToVisibilityConverter />
</converters:ConverterGroup>
</Binding.Converter>
</Binding>
</TabItem.Visibility>
The ConvertGroup allows for multiple converters to be run sequentially.
The ExpressionConverter lets you define an arbitrary expression. In my case I want the TabItem to be visible if the collection count is greater than zero. Being defined in xaml means escaping characters and a somewhat awkward syntax but it works well enough!
The BooleanToVisibilityConverter converts the boolean result from the expression to our desired visibility.
For Elham, BudgetControlType could be bound to as long as it implemented INotifyPropertyChanged. An equals expression is done like this (I'm returning true if the bound value equals 7):
<converters:ExpressionConverter Expression="{}{0} == 7" />
You can use 1,2,4,8,... and convert it to Visibility
for example if your int number is 6 (2+4) then Control with paramerter 2 and Control with parameter 4 is Visible!
public class IntToVisibilityConverter:IValueConverter
{
private int val;
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
int intParam = (int)parameter;
val = (int)value;
return ((intParam & val) != 0) ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
And in xaml :
<ComboBox Visibility="{Binding Path=MyEnum,UpdateSourceTrigger=PropertyChanged, Converter={StaticResource IntToVisibilityConverter}, ConverterParameter=1}"/>
<ComboBox Visibility="{Binding Path=MyEnum,UpdateSourceTrigger=PropertyChanged, Converter={StaticResource IntToVisibilityConverter}, ConverterParameter=2}"/>
<ComboBox Visibility="{Binding Path=MyEnum,UpdateSourceTrigger=PropertyChanged, Converter={StaticResource IntToVisibilityConverter}, ConverterParameter=4}"/>
The best way I'd say would be to go with properties on your ViewModel, and bind to them.
example (you'll have to massage it a bit, but it's fairly simple from here) :
public Visibility dtcb1 { get; set; }
// all the rest till 7
// Somewhere in your logit / constructor :
dtcb1 = BudgetControlType == 1 ? Visible : Hidden;
// and so on
And on your xaml you'll bind your visibility to dtcb1
You can make the property boolean, and use a boolean to visibility converter as well (as per this answer for example, or just google yourself)

Understanding System.Windows.Data Error: 23 : Cannot convert

I've struggled to understand this error for some time and now it's finally breaking something. Here's a dumbed-down sketch of what I'm doing:
My datawrapper class:
class DummyWrapper<T> : INotifyPropertyChanged
{
public DummyWrapper() { }
private T _data;
public T Data
{
get { return _data; }
set
{
_data = value;
Notify("Data");
}
}
public static implicit operator T(DummyWrapper<T> d)
{
return d._data;
}
...
}
My XAML:
<DockPanel>
<ContentPresenter Name="cp" Visibility="Collapsed"/>
<Rectangle Name="foo" Fill="{Binding ElementName=cp, Path=Content}" Height="50" Width="50"/>
</DockPanel>
The pertinent bit of my codebehind:
DummyWrapper<Brush> dw = new DummyWrapper<Brush>(new SolidColorBrush((Color)ColorConverter.ConvertFromString("Red")));
cp.Content = dw;
And of course if this was all working the way I expected I wouldn't be here. The output window shows me this:
System.Windows.Data Error: 23 : Cannot convert 'WpfTestApplication.DummyWrapper`1[System.Windows.Media.Brush]'
from type 'DummyWrapper`1' to type 'System.Windows.Media.Brush'
for 'en-US' culture with default conversions; consider using Converter property of Binding.
... and it goes on in that vein for some time.
Is there something I can do to allow my DummyWrapper to be converted automatically (ie w/o supplying a converter in the binding) in this context?
Change your line of code to
var solidColorBrush = new SolidColorBrush((Color) ColorConverter.ConvertFromString("Red"));
DummyWrapper<Brush> dw = new DummyWrapper<Brush>(solidColorBrush);
cp.Content = (Brush)dw;
You don't want to use converters that's fine. Content is an object and doing an implicit operator will not just do that unless the Content is of type Brush. You have to explicitly cast it to Brush
System.Object is the type of the Content property.
Through inheritance there's already an implicit conversion to the base
type

WPF Binding.ValidationRules at Runtime

I'm in the process of writing validation Rules to various controls in XAML. I would like to attach validationRules to controls at runtime and not in XAML. I was thinking of using Converters . but any ideas / thoughts which would be better way to accomplish this.
Sample code:
<TextBox Name="txtFirstName" > <TextBox.Text> <Binding Path="FirstName" ValidatesOnDataErrors="True" PropertyChanged" >
<Binding.ValidationRules>
<Binding Converter="{StaticResource validationConverter}"/>
</Binding.ValidationRules>
</Binding>
public class ValidationConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
Binding b = new Binding();
b.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
b.ValidatesOnDataErrors = true;
b.NotifyOnValidationError = true;
b.ValidationRules.Add(new RangeValidationRule { ErrorMessage = "Error shown from Converter ", MinValue = 10, MaxValue = 50 });
return b;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
Thanks,
A method that I have used is to create different Styles that have my custom validation built into them. Then it is just a matter of assigning the proper Style at runtime that contains the validation that is needed.
EDIT
Below is a basic example that creates a style called NumericTextBox:
<Style x:Key="NumericTextBox">
<Setter Property="TextBox.VerticalAlignment"
Value="Stretch"/>
<Setter Property="TextBox.VerticalContentAlignment"
Value="Center"/>
<Setter Property="TextBox.Height"
Value="24"/>
<Setter Property="TextBox.Margin"
Value="0,2,0,2"/>
<EventSetter Event="UIElement.PreviewTextInput"
Handler="tbx_DigitCheck"/>
<EventSetter Event="UIElement.PreviewKeyDown"
Handler="tbx_OtherCharCheck"/>
<EventSetter Event="UIElement.PreviewDragEnter"
Handler="tbx_PreviewDragEnter"/>
</Style>
The following method is put in the code-behind file for the resource dictionary where the Style is stored. This method makes sure that only numbers and the valid decimal separator can be entered in the textbox. Each character is checked for vailidity before it is actually displayed in the textbox.
Public Sub tbx_DigitCheck(ByVal sender As Object, _
ByVal e As TextCompositionEventArgs)
//Retireve the sender as a textbox.
Dim tbx As TextBox = CType(sender, TextBox)
Dim val As Short
//Get the current decimal separator.
Dim dSep As String = Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator
//Check to make sure that a decimal separator character has not
//already been entered in the textbox. Only make this check
//for areas of the text that are not selected.
If e.Text = dSep And tbx.SelectedText.Contains(dSep) Then
//Do Nothing. Allow the character to be typed.
ElseIf e.Text = dSep And tbx.Text.Contains(dSep) Then
e.Handled = True
End If
//Only allow the decimal separator and numeric digits.
If Not Int16.TryParse(e.Text, val) And Not e.Text = dSep Then
e.Handled = True
End If
End Sub

Can a c#.net class be automatically initialized by databinding to one of the properties of the class?

I am following a tutorial on http://msdn.microsoft.com/en-us/wp7trainingcourse_usingbingmapslab_topic3#_Toc271039355.
Source code can be found here: http://az12722.vo.msecnd.net/wp7trainingcourse1-4/labs/usingbingmapslab1-1-0/Source.zip. Select the second project called "Ex2-HandlingPushpins"
This tutorial shows how to place pins on a Bing map by long-pressing a location on the map.
In this tutorial there is a class PushpinCatalog, containing a collection of pushpins (Items). Items is bound to a ListBox control like this:
<Popup x:Name="PushpinPopup" IsOpen="False" Canvas.Top="330" Canvas.Left="45" Opacity="0">
<ListBox x:Name="ListBoxPushpinCatalog"
Width="392" Height="56"
Background="{StaticResource ControlBackgroundBrush}"
ItemsSource="{Binding Items}"
SelectionChanged="ListBoxPushpinCatalog_SelectionChanged">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Image Width="56" Height="56" Source="{Binding Icon}" />
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.DataContext>
<models:PushpinCatalog />
</ListBox.DataContext>
</ListBox>
</Popup>
And the Items collection is initialized in the constructor of the PushpinCatalog.
My question is, when does the constructor of the PushpinCatalog get called? I tried right-clicking it and selecting "Find all references" in visual studio, but there are none.
If I debug, the call stack shows this:
> UsingBingMaps.dll!UsingBingMaps.Models.PushpinCatalog.PushpinCatalog() Line 44 + 0x6 bytes C#
mscorlib.dll!System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo rtci, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object parameters, System.Globalization.CultureInfo culture, bool isBinderDefault, System.Reflection.Assembly caller, bool verifyAccess, ref System.Threading.StackCrawlMark stackMark)
mscorlib.dll!System.Reflection.RuntimeConstructorInfo.InternalInvoke(object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object[] parameters, System.Globalization.CultureInfo culture, ref System.Threading.StackCrawlMark stackMark) + 0x114 bytes
mscorlib.dll!System.Reflection.ConstructorInfo.Invoke(object[] parameters) + 0xa bytes
System.Windows.dll!MS.Internal.TypeProxy.GetCreateObjectDelegate.AnonymousMethod__2a() + 0xb bytes
System.Windows.dll!MS.Internal.TypeProxy.CreateInstance(uint customTypeId) + 0x12 bytes
System.Windows.dll!MS.Internal.FrameworkCallbacks.CreateKnownObject(System.IntPtr nativeRootPeer, uint customTypeId, string initializationString, out System.IntPtr nativePeer, uint isCreatedByParser) + 0x7a bytes
[External Code]
System.Windows.dll!MS.Internal.XcpImports.Application_LoadComponentNative(System.IntPtr pContext, System.IntPtr pComponent, uint cUriStringLength, string uriString, uint cXamlStrLength, byte* pXamlStr, uint cAssemblyStrLength, string assemblyStr)
System.Windows.dll!MS.Internal.XcpImports.Application_LoadComponent(MS.Internal.IManagedPeerBase componentAsDO, string resourceLocator, System.IO.UnmanagedMemoryStream stream, uint numBytesToRead, string assemblyString) + 0x39 bytes
System.Windows.dll!System.Windows.Application.LoadComponent(object component, System.Uri resourceLocator) + 0x136 bytes
UsingBingMaps.dll!UsingBingMaps.MainPage.InitializeComponent() Line 90 + 0x11 bytes C#
UsingBingMaps.dll!UsingBingMaps.MainPage.MainPage() Line 51 + 0x6 bytes C#
mscorlib.dll!System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo rtci, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object parameters, System.Globalization.CultureInfo culture, bool isBinderDefault, System.Reflection.Assembly caller, bool verifyAccess, ref System.Threading.StackCrawlMark stackMark)
mscorlib.dll!System.Reflection.RuntimeConstructorInfo.InternalInvoke(object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object[] parameters, System.Globalization.CultureInfo culture, ref System.Threading.StackCrawlMark stackMark) + 0x114 bytes
mscorlib.dll!System.Activator.InternalCreateInstance(System.Type type, bool nonPublic, ref System.Threading.StackCrawlMark stackMark) + 0xf0 bytes
mscorlib.dll!System.Activator.CreateInstance(System.Type type) + 0x2 bytes
Microsoft.Phone.dll!System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(System.AsyncCallback userCallback, System.Windows.Navigation.PageResourceContentLoader.PageResourceContentLoaderAsyncResult result) + 0xe6 bytes
Microsoft.Phone.dll!System.Windows.Navigation.PageResourceContentLoader.BeginLoad.AnonymousMethod__0(object args) + 0x11 bytes
mscorlib.dll!System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo rtmi, object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object parameters, System.Globalization.CultureInfo culture, bool isBinderDefault, System.Reflection.Assembly caller, bool verifyAccess, ref System.Threading.StackCrawlMark stackMark)
mscorlib.dll!System.Reflection.RuntimeMethodInfo.InternalInvoke(object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object[] parameters, System.Globalization.CultureInfo culture, ref System.Threading.StackCrawlMark stackMark) + 0x168 bytes
mscorlib.dll!System.Reflection.MethodBase.Invoke(object obj, object[] parameters) + 0xa bytes
mscorlib.dll!System.Delegate.DynamicInvokeOne(object[] args) + 0x98 bytes
mscorlib.dll!System.MulticastDelegate.DynamicInvokeImpl(object[] args) + 0x8 bytes
mscorlib.dll!System.Delegate.DynamicInvoke(object[] args) + 0x2 bytes
System.Windows.dll!System.Windows.Threading.DispatcherOperation.Invoke() + 0xc bytes
System.Windows.dll!System.Windows.Threading.Dispatcher.Dispatch(System.Windows.Threading.DispatcherPriority priority) + 0x83 bytes
System.Windows.dll!System.Windows.Threading.Dispatcher.OnInvoke(object context) + 0x8 bytes
System.Windows.dll!System.Windows.Hosting.CallbackCookie.Invoke(object[] args) + 0x19 bytes
System.Windows.dll!System.Windows.Hosting.DelegateWrapper.InternalInvoke(object[] args) + 0x2 bytes
System.Windows.RuntimeHost.dll!System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(System.IntPtr pHandle, int nParamCount, System.Windows.Hosting.NativeMethods.ScriptParam[] pParams, ref System.Windows.Hosting.NativeMethods.ScriptParam pResult) + 0x5e bytes
[External Code]
I suspect that through databinding of one of the properties of the class, the containing class is somehow automatically initialized, can anyone explain?
The PushpinCatalog class was created during XAML processing.
<ListBox.DataContext>
<models:PushpinCatalog /> - PushpinCatalog instance creation
</ListBox.DataContext>
After it the DataContext property of ListBox has a reference to you PushpinCatalog model instance.

Resources