Click here to Skip to main content
       

Silverlight / WPF

 
GeneralRe: RoutedEvent vs AttachedEvent Pinmemberdevvvy30-Jan-13 2:40 
GeneralRe: RoutedEvent vs AttachedEvent PinprotectorPete O'Hanlon30-Jan-13 2:44 
GeneralRe: RoutedEvent vs AttachedEvent Pinmemberdevvvy30-Jan-13 3:08 
QuestionWPF Tab Item Close Button [modified] PinmemberKevin Marois29-Jan-13 18:03 
I created a tab stle so that it has a close button. The button is bound to a command:
<Style TargetType="{x:Type TabItem}">
    <Setter Property="ContextMenu">
        <Setter.Value>
            <ContextMenu>
                <MenuItem Header="Close"
                            Command="{Binding CloseTabCommand}"/>
                <MenuItem Header="Close All But This" 
                            Command="{Binding CloseAllOtherTabsCommand}"/>
                <MenuItem Header="Float"
                            Command="{Binding FloatTabCommand}"/>
            </ContextMenu>
        </Setter.Value>
    </Setter>
</Style>
 
I tried this:
<MenuItem Header="Close"
            Command="{Binding CloseTabCommand}"
            CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabItem}}}"/>
 
but I get null passed to the command.
 
I need to pass along a reference to the tab. Can someone show me how to get the tab in this style and pass it as a parameter?
 

 
Thank you
If it's not broken, fix it until it is


modified 30-Jan-13 0:12am.

AnswerRe: WPF Tab Item Close Button PinmemberSledgeHammer0129-Jan-13 19:02 
GeneralRe: WPF Tab Item Close Button PinmemberKevin Marois2-Feb-13 15:33 
GeneralRe: WPF Tab Item Close Button PinmemberSledgeHammer012-Feb-13 18:25 
QuestionCustom Control Template for beginners Pinmemberjeffdavis870329-Jan-13 9:12 
AnswerRe: Custom Control Template for beginners PinmemberSledgeHammer0129-Jan-13 11:32 
GeneralRe: Custom Control Template for beginners Pinmemberjeffdavis870329-Jan-13 12:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 18 Sep 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid