Formular una preguntaFormular una pregunta
 

PreguntaPage navigation in a frame throws an exception

  • miércoles, 04 de noviembre de 2009 3:41wiktor256 Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Tiene código
    I created a very simple WPF project that exhibits the following error. I have no idea how to get of this error.

    System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Menu', AncestorLevel='1''. BindingExpression:Path=TemplatedParent; DataItem=null; target element is 'MenuItem' (Name=''); target property is 'CommandTarget' (type 'IInputElement')
    

    Steps to reproduce:
    1. Create a WPF Application project in Visual Studio 2008 (Windows 7)
    2. Create Page1.xaml
    <Page x:Class="WpfApplication1.Page1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Page1">
        <TextBlock>
            <Hyperlink NavigateUri="Page2.xaml">Page 2</Hyperlink>
        </TextBlock>
    </Page>
    

    3. Create Page2.xaml

    <Page x:Class="WpfApplication1.Page2"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Page2">
        <TextBlock>
            <Hyperlink NavigateUri="Page1.xaml">Page 1</Hyperlink>
        </TextBlock>
    </Page>
    

    4. Add a frame in Window1.xaml

    <Window x:Class="WpfApplication1.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300">
        <Frame Source="Page1.xaml"/>
    </Window>
    


    5. Build it and run it.
    6. Click on a link "Page 2".
        Note: all navigation using hyper links, and browser "Back" and "Forward" arrows works great until a page is selected from the navigation history.
    7. From the navigation bar select a previous page from the navigation history. At this moment the following errors appear.

    System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Menu', AncestorLevel='1''. BindingExpression:Path=TemplatedParent; DataItem=null; target element is 'MenuItem' (Name=''); target property is 'CommandTarget' (type 'IInputElement')
    System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Menu', AncestorLevel='1''. BindingExpression:Path=TemplatedParent; DataItem=null; target element is 'MenuItem' (Name=''); target property is 'CommandTarget' (type 'IInputElement')
    System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Menu', AncestorLevel='1''. BindingExpression:Path=TemplatedParent; DataItem=null; target element is 'MenuItem' (Name=''); target property is 'CommandTarget' (type 'IInputElement')
    System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Menu', AncestorLevel='1''. BindingExpression:Path=TemplatedParent; DataItem=null; target element is 'MenuItem' (Name=''); target property is 'CommandTarget' (type 'IInputElement')
    System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Menu', AncestorLevel='1''. BindingExpression:Path=TemplatedParent; DataItem=null; target element is 'MenuItem' (Name=''); target property is 'CommandTarget' (type 'IInputElement')
    System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Menu', AncestorLevel='1''. BindingExpression:Path=TemplatedParent; DataItem=null; target element is 'MenuItem' (Name=''); target property is 'CommandTarget' (type 'IInputElement')
    


    Can anyone explain this?










Todas las respuestas

  • miércoles, 04 de noviembre de 2009 17:47wiktor256 Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    The same error can be seen in MSFT sample application: http://msdn.microsoft.com/en-us/library/aa358506.aspx
  • jueves, 05 de noviembre de 2009 10:13Linda LiuMSFT, ModeradorMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    Hi Wiktor,

    I performed a test based on your description and did reproduce the problem on my side. I have searched our database but didn't find a similar issue in it. I will consult this issue to our product team.

    As soon as I get a reply, I will get it back to you. I appreciate your patience!

    Sincerely,
    Linda Liu
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • martes, 10 de noviembre de 2009 3:58Linda LiuMSFT, ModeradorMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    Hi Wiktor,

    I have reported a feedback through Visual Studio & .NET Connect site:
    (https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=509427).

    This issue will be routed to the product unit who works on this specific feature area for triage and resolution. I’ll paste all responses from the product unit in this thread. And you also can click the link and add the feedback to your watchlist ( you need to log in using your account) so that you can get informed as soon as product units respond.  It may be some time before we get response from product unit. Please be patient.

    Sincerely,
    Linda Liu
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.