Click here to Skip to main content
15,913,773 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Richard Deeming22-Aug-18 2:21
mveRichard Deeming22-Aug-18 2:21 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Pew_new23-Aug-18 0:41
Pew_new23-Aug-18 0:41 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Richard Deeming23-Aug-18 8:15
mveRichard Deeming23-Aug-18 8:15 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Pew_new23-Aug-18 8:34
Pew_new23-Aug-18 8:34 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Richard Deeming23-Aug-18 8:39
mveRichard Deeming23-Aug-18 8:39 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Pew_new23-Aug-18 8:52
Pew_new23-Aug-18 8:52 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Richard Deeming23-Aug-18 9:05
mveRichard Deeming23-Aug-18 9:05 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Pew_new24-Aug-18 3:09
Pew_new24-Aug-18 3:09 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Gerry Schmitz24-Aug-18 6:08
mveGerry Schmitz24-Aug-18 6:08 
GeneralRe: WPF: Can't get what I need to do to get things right (responsive controls). Pin
Pew_new25-Aug-18 7:36
Pew_new25-Aug-18 7:36 
QuestionScale items with ViewBox within an ItemsControl Pin
Kenneth Haugland7-Aug-18 6:07
mvaKenneth Haugland7-Aug-18 6:07 
AnswerRe: Scale items with ViewBox within an ItemsControl Pin
Kenneth Haugland8-Aug-18 3:56
mvaKenneth Haugland8-Aug-18 3:56 
QuestionPredicateBuilder Question Pin
Kevin Marois14-Jul-18 18:21
professionalKevin Marois14-Jul-18 18:21 
AnswerRe: PredicateBuilder Question Pin
Richard Deeming16-Jul-18 8:19
mveRichard Deeming16-Jul-18 8:19 
AnswerRe: PredicateBuilder Question Pin
Gerry Schmitz16-Jul-18 10:15
mveGerry Schmitz16-Jul-18 10:15 
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
mvePete 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
mvePete 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
mvePete 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 

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.