Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Why doesn't this databind???

$
0
0

I have the following very simple XAML:

<Window x:Class="WpfApplication7.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"><Window.Resources><Style x:Key="TabControl_Header_Style" TargetType="{x:Type TabItem}"><Setter Property="HeaderTemplate"><Setter.Value><DataTemplate><TextBlock Text="{Binding Path=ThisDoesNotDatabind}"/><!--<TextBlock Text="ALiteralValueWorks"/>--></DataTemplate></Setter.Value></Setter></Style></Window.Resources><Grid><TabControl Grid.Row="1" ItemContainerStyle="{StaticResource TabControl_Header_Style}"><TabItem>"Hej Hej A"</TabItem><TabItem>"Hej Hej B"</TabItem></TabControl></Grid></Window>

My question is, why doesn't the TextBlock.Text databind to the property ThisDoesNotDatabind??? Simply the TextBlock.Text remains empty and there's no error in the output window when run in debug-mode in VS 2013.

If I comment that line and instead uncomment "<TextBlock Text="ALiteralValueWorks"/>", the TextBlock.Text will contain "ALiteralValueWorks".

Therefore I know that the TextBlock is being used but databinding doesn't work.

I hope somebody can explain this, more precisely how to make the Text="{Binding Path=ThisDoesNotDatabind}" to actually do data binding, please?

Best regards,

Henrik Dahl


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>