WPF: Binding a DataTemplate to list items _and_ static values

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top