The following code works fine,
<ContextMenu ItemsSource="{Binding SourceA}" Visibility="{Binding SourceAVisible,Converter={StaticResource BoolToHiddenConverter}}" />
I thought the following code is the equivalent, however it throws a runtime exception saying the items collection must be cleared before using ItemsSource.
<ContextMenu ItemsSource="{Binding SourceA}">
<Style TargetType="{x:Type ContextMenu}">
<Setter Property="ContextMenu.Visibility" Value="{Binding SourceAVisible,Converter={StaticResource BoolToHiddenConverter}}"/>
</Style>
</ContextMenu>
if you put anything between the tags of an item it is assumed to be the content (in this case the ItemsSource which is already set). You need to implicitly tell WPF that you are setting the value of the style.