I'm wondering how do I set the bindings to a public variable within my Viewmodel WorkTabViewModel. I set two examples I tried below,
The Foreground="{Binding MenuItemForeground}"
and
Foreground="{Binding MenuItemForeground, RelativeSource={RelativeSource AncestorType=UserControl}}"
But they both don't recognize MenuItemForeground.
<TextBlock VerticalAlignment="Center" FontWeight="Bold" Margin="1 0 0 0" DataContext="{Binding Path=DataContext, RelativeSource={RelativeSource AncestorType=UserControl}}" >
<TextBlock.ContextMenu>
<ContextMenu>
<MenuItem Header="Close tab" cal:Message.Attach="[Click] = [CloseTab()]" />
<MenuItem Header="Close other tabs" cal:Message.Attach="[Click] = [CloseOtherTabs()]" IsEnabled="False" Foreground="{Binding MenuItemForeground, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
<MenuItem Header="Close all tabs" cal:Message.Attach="[Click] = [CloseAllTabs()]" IsEnabled="False" Foreground="{Binding MenuItemForeground}"/>
</ContextMenu>
</TextBlock.ContextMenu>
</TextBlock>
WorkTabViewModel
public Brush MenuItemForeground { get; set; }
public void CloseTab(){...}
public void CloseOtherTab(){...}
public void CloseAllTabs(){...}