[Unity] TabControl using ItemsSource throws exception
Posted: 20 Sep 2014, 20:49
As the subject says, I'm just trying to populate a TabControl with items by binding a Collection to the ItemsSource. Doing so results in the following exception:
Xaml:
Code UserControl:
Code TestTabItem:
Am I doing anything wrong or is this a bug?
Code: Select all
{{{
Unhandled exception at 0x24471409: Access Violation reading location 0x8E3F1AA0
}}}
{{{
[ 0] [0x24471409] Noesis.dll!Noesis::Gui::DependencyPropertyChangedEventArgs::GetClassType + 0xc9 bytes
[ 1] [0x24471B4C] Noesis.dll!Noesis::Gui::DependencyObject::InternalGetValue + 0x1c bytes
[ 2] [0x244CBB19] Noesis.dll!Noesis::Gui::BaseTextBox::UpdateVisualStates + 0x5299 bytes
[ 3] [0x245E5649] Noesis.dll!Noesis::Gui::TabItem::SetIsSelected + 0x29 bytes
[ 4] [0x245E504A] Noesis.dll!Noesis::Gui::TabControl::OnSelectionChanged + 0x3a bytes
[ 5] [0x245D21E8] Noesis.dll!Noesis::Gui::Selector::ManageSingleSelectionChanged + 0x1b8 bytes
[ 6] [0x245D271E] Noesis.dll!Noesis::Gui::Selector::OnPropertyChanged + 0x3e bytes
[ 7] [0x24597069] Noesis.dll!Noesis::Gui::Popup::StaticOnPopupLostMouseCapture + 0xad9 bytes
[ 8] [0x244CBFCF] Noesis.dll!Noesis::Gui::BaseTextBox::UpdateVisualStates + 0x574f bytes
[ 9] [0x245D1DB9] Noesis.dll!Noesis::Gui::Selector::SetSelectedIndex + 0x29 bytes
[10] [0x245E3FDE] Noesis.dll!Noesis::Gui::TabControl::OnItemsChanged + 0x2e bytes
[11] [0x24557591] Noesis.dll!Noesis::Gui::ItemsControl::OnItemsChangedInternal + 0x11 bytes
[12] [0x24556666] Noesis.dll!Noesis::Gui::ItemCollection::OnCollectionChanged + 0x16 bytes
[13] [0x244E53F1] Noesis.dll!Noesis::Gui::CollectionView::InternalCollectionChanged + 0x21 bytes
[14] [0x244E4A19] Noesis.dll!Noesis::Gui::Collection::Add + 0xa9 bytes
[15] [0x24713309] Noesis.dll!Collection_Add__SWIG_0 + 0x59 bytes
[16] [0x1BAEAA69]
[17] [0x0BC003FC] mono.dll!mono_gc_wbarrier_arrayref_copy + 0x26f9 bytes
[18] [0x0BAF1D44] mono.dll!g_free + 0x316 bytes
}}}
Code: Select all
<TabControl ItemsSource="{Binding Tabs2}" />
Code: Select all
Collection _tabs2;
public Collection Tabs2
{
get { return _tabs2; }
set
{
if (value != _tabs2)
{
_tabs2 = value;
NotifyPropertyChanged("Tabs2");
}
}
}
public override void OnPostInit()
{
base.OnPostInit();
Tabs2 = new Collection();
Tabs2.Add(new TestTabItem() { Header = "Test 1" });
Tabs2.Add(new TestTabItem() { Header = "Test 2" });
}
Code: Select all
[Extended]
public class TestTabItem : BaseComponent
{
string _header;
public string Header
{
get { return _header; }
set
{
if (value != _header)
{
_header = value;
NotifyPropertyChanged("Header");
}
}
}
}