I have a WPF form with a content control
and a custom control
. The content control
swaps in views based on a radio button selection. Once the user takes an action on the view, I set the nocustomer on the parent viewmodel
(the WPF form containing the two controls) to false. When this occurs, the visibility of content control
correctly disappears. Unfortunately, the visibility of the custom control
remains unchanged (it should have also disappeared). I'm actually perplexed because in my mind they have the exact same implementation and therefore should behave the same.
<ContentControl x:Name="ViewSwap" Content="{Binding SearchingViewModel}"
Visibility="{Binding NoCustomer, Converter={StaticResource
BooleanToVisibilityConverter}, Mode=OneWay}">
<ContentControl.Style>
<Style TargetType="{x:Type ContentControl}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=SearchOptions, Path=IsSelected}" Value="0">
<Setter Property="ContentTemplate" Value="{StaticResource AddressTemplate}" />
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
</ContentControl>
<views:CTACallSubmit x:Name="CallSubmit"
Visibility="{Binding NoCustomer, Converter={StaticResource
BooleanToVisibilityConverter}, Mode=OneWay}"/>
Update:
MainWindow's DataContext
public partial class CTALight : Window
{
public CTALight()
{
InitializeComponent();
this.DataContext = CTALightViewModel.GetInstance();
}
}
MainViewModel
public class CTALightViewModel : ObservableObject
{
public static CTALightViewModel _mainViewModel;
public static CTALightViewModel GetInstance()
{
if (_mainViewModel == null)
_mainViewModel = new CTALightViewModel();
return _mainViewModel;
}
private CTALightViewModel()
{
}
}
CTACallSubmit DataContext
<UserControl.DataContext>
<viewmodel:CTACallSubmitViewModel />
</UserControl.DataContext>