Alex141 / CalcBinding

Advanced WPF Binding which supports expressions in Path property and other features

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DataTemplate bind to the whole item

xmedeko opened this issue · comments

I have a <ListBox> with <DataTemplate> and I need to bind Visibility to the condition, if the item is null or not. In a bare WPF I use

<TextBlock Text="Item is null" Visibility="{Binding Converter={StaticResource IsNullConverter}}" />

However, I would like to use a fancy CalcBinding, something like

<TextBlock Text="Item is null" Visibility="{cb:Binding '. == null'" />

How to denote the whole item in the expression (. is not working).

As workaround I can offer this:
<TextBlock Text="Item is null" Visibility="{cb:Binding Path='DataContext == null', RelativeSource={RelativeSource Self}}" />