Take the 2-minute tour ×

I have an observable collection of objects bound to a tabcontrol from which I am generating tabs by binding it as an itemssource

    <TabControl x:Name="tabSubmodule" ItemsSource="{Binding}" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" TabStripPlacement="Left">
                <TextBlock Text="{Binding ., Converter={StaticResource NameConverter}}"/>
                <Label Content="{Binding ., Converter={StaticResource NameConverter}}"/>
                <ContentPresenter Content="{Binding ., Converter={StaticResource NameConverter}}"/>

I am supossed to trigger the Converter in the itemtemplate and based on the object generate the name of the tab and some other stuff. As you can see, the binding occurs (Path) on the whole object. I have a breakpoint in converter's ConvertMethod. It triggers fine.

The problem is, when the breakpoint triggers from the ItemTemplate, the "value" argument of the method is always null. I tried setting it to various controls (because of object or string expectation - content, text propetty). nothing. It is always null

When the converter triggers from the Contenttemplate, the value is not null, but the expected object.

any suggestions?

share|improve this question
I've just tried your code and in both cases value passed to Convert method is set to an object as expected –  dkozl Aug 17 '13 at 21:54
I still have the same bug. unbelievable. I've been doing this hundrets of times, but never seen anything like this. –  user853710 Aug 18 '13 at 8:55
So content is fine but header always stays empty? Even when you remove Converter from the Binding in ItemTemplate there is no ToString() representation of the object in the header? –  dkozl Aug 18 '13 at 10:21
exactly. Not even the tostring method is being called. Since everytzhing works fine in the ItemTemplate, this makes absolutelly no sense –  user853710 Aug 18 '13 at 10:49
add comment

1 Answer

I generally do a sanity check in my converters, and if the value is null, return Binding.DoNothing. Sometimes your converter will get a null value. The key is to not throw an exception.

share|improve this answer
add comment

Your Answer


