I just need a pair of extra eyes to see what i am doing wrong here.
I have a xaml page with a groupstyle inside a list view. here is how it looks,
<GroupStyle
HeaderContainerStyle="{StaticResource JumpListListHeaderContainerStyle}"
HidesIfEmpty="True">
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Border
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
BorderThickness="0,0,0,1"
BorderBrush="{StaticResource RedBrush}"
Margin="0,0,0,9.5">
<TextBlock Text="{Binding Key}"
Foreground="{StaticResource RedBrush}"
FontSize="23"
Visibility="{Binding IsGroupheaderVisible, Converter={StaticResource BooleanToVisibilityConverter}}"
FontFamily="Segoe WP Semibold"
OpticalMarginAlignment="TrimSideBearings"
VerticalAlignment="Bottom" />
</Border>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
What i need do is hide the groupstule header based on a condition in the viewmodel. Here's the property.
private bool _isGroupHeaderVisibile;
public bool IsGroupheaderVisible
{
get { return _isGroupHeaderVisibile; }
set
{
if (value == _isGroupHeaderVisibile) return;
_isGroupHeaderVisibile = value;
NotifyOfPropertyChange(() => IsGroupheaderVisible);
}
}
and on the OnInitialize event i am setting it to true or false based on some condition. But unfortunately it does not hide/show but always shows up.
Here's the BooleanToVisibilityConverter that i am using,
public class BooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
bool flag;
return value != null && bool.TryParse(value.ToString(), out flag) && flag
? Visibility.Visible
: Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return value is Visibility && (Visibility)value == Visibility.Visible;
}
}
NOTE: I am using CaliburnMicro, so i have methods like OnInitialize() which i am omitting.