WPF: Binding a DataTemplate to list items _and_ static values

  • Thread starter Thread starter Julia M
  • Start date Start date
J

Julia M

Hi,

I'm trying to bind a datatemplate to both listItems and a visibiltiy
value which is not part of the list itself.

e.g.

public Visibility VisibilityInfo;
public List<Stuff> MyListItems;

<ItemsControl ItemsSource="{Binding Path=MyListItems}" >
...
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Path=ItemText}" />
<TextBlock Text="{Binding Path=ItemInfo}" Visibility={Binding
Path=VisibilityInfo} />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

Listing all "ItemText" works pretty well but , of course, "ItemInfo"
never shows up because VisibilityInfo is no part of MyListItems.
How do I "escape" the visibility path?
Using template selectors etc wouldn't really help since all this is
part of a usercontrol.
I somehow need to tap into the DataContext itself - not MyListItems.

TIA
 
Back
Top