Click here to Skip to main content
14,270,034 members

Silverlight / WPF

 
QuestionWPF HyperLink Binding To MainWindowViewMOdel Not Working Pin
Kevin Marois9-Jul-18 17:02
professionalKevin Marois9-Jul-18 17:02 
AnswerRe: WPF HyperLink Binding To MainWindowViewMOdel Not Working Pin
Pete O'Hanlon9-Jul-18 20:07
protectorPete O'Hanlon9-Jul-18 20:07 
GeneralRe: WPF HyperLink Binding To MainWindowViewMOdel Not Working Pin
Kevin Marois10-Jul-18 6:53
professionalKevin Marois10-Jul-18 6:53 
QuestionBind TabItem ContexMenu Command To Window VM Pin
Kevin Marois8-Jul-18 12:03
professionalKevin Marois8-Jul-18 12:03 
AnswerRe: Bind TabItem ContexMenu Command To Window VM Pin
Richard Deeming9-Jul-18 8:35
mveRichard Deeming9-Jul-18 8:35 
GeneralRe: Bind TabItem ContexMenu Command To Window VM Pin
Kevin Marois9-Jul-18 16:23
professionalKevin Marois9-Jul-18 16:23 
GeneralRe: Bind TabItem ContexMenu Command To Window VM Pin
Pete O'Hanlon10-Jul-18 7:08
protectorPete O'Hanlon10-Jul-18 7:08 
GeneralRe: Bind TabItem ContexMenu Command To Window VM Pin
Kevin Marois10-Jul-18 7:38
professionalKevin Marois10-Jul-18 7:38 
I have the window's name set to 'window'.

This is driving me nuts. I can't seem to get this right. here's what I have now:
<Style TargetType="TabItem">

    <Setter Property="ContextMenu">
        <Setter.Value>
            <ContextMenu DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType=Window}}"
                    x:Name="tabMenu">

                <MenuItem Header="Close" 
                    Command="{Binding CloseTabCommand}"
                    CommandParameter="{Binding}"/>

                <MenuItem Header="Close All Tabs" 
                    Command="{Binding CloseAllTabsCommand}"
                    CommandParameter="{Binding}"/>

                <MenuItem Header="Close All But This" 
                    Command="{Binding CloseAllButThisTabCommand}"
                    CommandParameter="{Binding}"/>

            </ContextMenu>
        </Setter.Value>
    </Setter>

    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="TabItem">
                <Grid Name="Panel">
                    <ContentPresenter x:Name="ContentSite"
                                VerticalAlignment="Center"
                                HorizontalAlignment="Center"
                                ContentSource="Header"
                                Margin="10,2"/>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsSelected" Value="True">
                        <Setter TargetName="Panel" Property="Background" Value="LightSkyBlue" />
                    </Trigger>
                    <Trigger Property="IsSelected" Value="False">
                        <Setter TargetName="Panel" Property="Background" Value="White" />
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>

</Style>
The Output Window shows
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Window', AncestorLevel='1''. BindingExpression:Path=DataContext; DataItem=null; target element is 'ContextMenu' (Name='tabMenu'); target property is 'DataContext' (type 'Object')
Again, it looks like it can't find the Window.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

GeneralRe: Bind TabItem ContexMenu Command To Window VM Pin
Pete O'Hanlon10-Jul-18 10:40
protectorPete O'Hanlon10-Jul-18 10:40 
GeneralRe: Bind TabItem ContexMenu Command To Window VM Pin
Kevin Marois10-Jul-18 11:21
professionalKevin Marois10-Jul-18 11:21 
GeneralRe: Bind TabItem ContexMenu Command To Window VM Pin
Kevin Marois15-Jul-18 16:08
professionalKevin Marois15-Jul-18 16:08 
AnswerRe: Bind TabItem ContexMenu Command To Window VM Pin
NaBian18-Sep-18 5:11
memberNaBian18-Sep-18 5:11 
QuestionListBox of Hyperlinks - Selected Item Pin
Kevin Marois6-Jul-18 19:37
professionalKevin Marois6-Jul-18 19:37 
AnswerRe: ListBox of Hyperlinks - Selected Item Pin
Mycroft Holmes7-Jul-18 13:38
memberMycroft Holmes7-Jul-18 13:38 
AnswerRe: ListBox of Hyperlinks - Selected Item Pin
Richard Deeming9-Jul-18 8:32
mveRichard Deeming9-Jul-18 8:32 
QuestionWhat is Silverlight / WPF??? Pin
Arnav12130-Jun-18 20:03
memberArnav12130-Jun-18 20:03 
AnswerRe: What is Silverlight / WPF??? Pin
Richard MacCutchan30-Jun-18 20:50
protectorRichard MacCutchan30-Jun-18 20:50 
QuestionNested Borders Mouse Over Pin
Kevin Marois14-Jun-18 7:44
professionalKevin Marois14-Jun-18 7:44 
AnswerRe: Nested Borders Mouse Over Pin
Richard Deeming14-Jun-18 9:35
mveRichard Deeming14-Jun-18 9:35 
GeneralRe: Nested Borders Mouse Over Pin
Kevin Marois14-Jun-18 10:51
professionalKevin Marois14-Jun-18 10:51 
QuestionWPF DataGrid uses a lot of memory, or is slow to scroll Pin
Leif Simon Goodwin14-Jun-18 5:16
memberLeif Simon Goodwin14-Jun-18 5:16 
AnswerRe: WPF DataGrid uses a lot of memory, or is slow to scroll Pin
Pete O'Hanlon14-Jun-18 5:21
protectorPete O'Hanlon14-Jun-18 5:21 
GeneralRe: WPF DataGrid uses a lot of memory, or is slow to scroll Pin
Leif Simon Goodwin14-Jun-18 21:18
memberLeif Simon Goodwin14-Jun-18 21:18 
AnswerRe: WPF DataGrid uses a lot of memory, or is slow to scroll Pin
Gerry Schmitz14-Jun-18 8:01
mveGerry Schmitz14-Jun-18 8:01 
GeneralRe: WPF DataGrid uses a lot of memory, or is slow to scroll Pin
Leif Simon Goodwin14-Jun-18 21:59
memberLeif Simon Goodwin14-Jun-18 21:59 

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

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