Note that there are some explanatory texts on larger screens.

plurals
  1. POHide the group header of a listview by binding in Windows Store App
    primarykey
    data
    text
    <p>I'm trying to remove group headers for groups where the header title is empty. But I can not make the binding in HeaderContainerStyle work. Neither can I set visibility on the TextBlock in TemplateHeader 'cause that will leave a small space and not be completely invisible. </p> <p>This is my XAML:</p> <pre><code>&lt;Page.Resources&gt; &lt;CollectionViewSource x:Name="MenuItemsGrouped" IsSourceGrouped="True" Source="{Binding MenuItems}" /&gt; &lt;/Page.Resources&gt; &lt;ListView Grid.Row="1" Margin="0" ItemsSource="{Binding Source={StaticResource MenuItemsGrouped}}" IsSynchronizedWithCurrentItem="False" SelectionMode="Single" SelectedItem="{Binding SelectedItem, Mode=TwoWay}"&gt; &lt;ListView.GroupStyle&gt; &lt;GroupStyle&gt; &lt;GroupStyle.HeaderTemplate&gt; &lt;DataTemplate&gt; &lt;TextBlock Text="{Binding Title}" /&gt; &lt;/DataTemplate&gt; &lt;/GroupStyle.HeaderTemplate&gt; &lt;GroupStyle.HeaderContainerStyle&gt; &lt;Style TargetType="ListViewHeaderItem"&gt; &lt;Setter Property="Visibility" Value="{Binding GroupHeaderVisibility}"&gt;&lt;/Setter&gt; &lt;/Style&gt; &lt;/GroupStyle.HeaderContainerStyle&gt; &lt;/GroupStyle&gt; &lt;/ListView.GroupStyle&gt; &lt;ListView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Margin="0" Orientation="Horizontal"&gt; &lt;TextBlock Text="{Binding Title}" /&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListView.ItemTemplate&gt; &lt;/ListView&gt; </code></pre> <p>Does anyone have a solution - and maybe a reason the binding won't work?</p> <p>EDIT:</p> <p>Ok, it's is actually a limitation in Windows Store Apps and earlier Silverlight apps:</p> <blockquote> <p>Windows Presentation Foundation (WPF) and Microsoft Silverlight supported the ability to use a Binding expression to supply the Value for a Setter in a Style. The Windows Runtime doesn't support a Binding usage for Setter.Value (the Binding won't evaluate and the Setter has no effect, you won't get errors, but you won't get the desired result either). When you convert XAML styles from WPF or Silverlight XAML, replace any Binding expression usages with strings or objects that set values, or refactor the values as shared StaticResource values rather than Binding-obtained values.</p> </blockquote> <p>from <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.setter" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.setter</a></p> <p>And see also <a href="https://stackoverflow.com/questions/4878189/silverlight-how-to-use-a-binding-in-setter-for-a-style-or-an-equivalent-work-a">Silverlight: How to use a binding in setter for a style (or an equivalent work around)</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload