I have a value converter that converts null to Visibility.Collapsed. Now I'm trying to use it in a user control so that the whole control is reset when the DateContext is null
The control is as follows:
<UserControl x:Class="PhoneApp.Controls.Header"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Visibility="{Binding Converter={StaticResource ToVisibility}}"
d:DesignHeight="150" d:DesignWidth="480"> <-- some body here -->
And it is used as
<my:Header DataContext="{Binding SectionHeader}"/>
Where SectionHeader is a property of the view model.
I have a similar control where I do not bind a DataContext, but some kind of custom DP and collapse there works fine. However, in this case, the value converter seems to be called only when SectionHeader! = Null. When it is zero, the control is displayed with empty children.
I thought that DataContext is not used here, but control with it is much cleaner.
DataContext ? ?