locked
XamlParseException occurred -- The method or operation is not implemented RRS feed

  • Question

  • I'am a newer to WPF, when i use MVVM and Prism to write my first WPF application, i meet an exception, the exception happend from the below code:

    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:ei=http://schemas.microsoft.com/expression/2010/interactions

    <Button Command="{Binding }" Content="Login" Grid.Row="1" IsEnabled="{Binding Path=IsLoginButtonEnabled}">
    <i:Interaction.Triggers>
    <i:EventTrigger EventName="Click">
    <ei:CallMethodAction TargetObject="{Binding}" MethodName="LoginEvent"/> -- This line have an exception "XamlParseException occurred" The method or operation is not implemented.
    </i:EventTrigger>
    </i:Interaction.Triggers>
    </Button>

    I use Prism and MEF to inject viewmodel to this view, and the "LoginEvent" is exists in viewmodel class LoginViewModel

    public void Login()
    {
    //Nothing to do.

    }

    the very strange thing is that i can not even use try ... catch... to catch this exception like this in the LoginView.cs file:

    try
    {

    InitializeComponent();
    }
    catch (Exception e)
    {

    }

    Is there anybody met this before, waitting for your help!!!!

    • Moved by Min Zhu Tuesday, November 15, 2011 2:07 AM (From:Windows Presentation Foundation (WPF))
    Sunday, November 13, 2011 3:27 PM

All replies

  • Hi Itigoo,

    Since you question is about Expression SDK, I have moved this thread to Expression Forum for better support.

    Best regards,


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, November 15, 2011 2:08 AM
  • Try setting your "TargetObject" to your "Window".

    Example:

    <i:Interaction.Triggers>
    				<i:EventTrigger EventName="Click">
    					<ei:CallMethodAction MethodName="myMethod" TargetObject="{Binding ElementName=Window}"/>
    				</i:EventTrigger>
    			</i:Interaction.Triggers>
    

     

    <Window
    	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    	xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
    	x:Class="WpfApplication2.MainWindow"
    	x:Name="Window"
    	Title="MainWindow"
    	Width="640" Height="480">
    
    	<Grid x:Name="LayoutRoot">
    		<Button x:Name="button" Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75">
    			<i:Interaction.Triggers>
    				<i:EventTrigger EventName="Click">
    					<ei:CallMethodAction MethodName="myMethod" TargetObject="{Binding ElementName=Window}"/>
    				</i:EventTrigger>
    			</i:Interaction.Triggers>
    		</Button>
    	</Grid>
    </Window
    
    public partial class MainWindow : Window
    	{
    		public MainWindow()
    		{
    			this.InitializeComponent();
    		}
    		
    		public void myMethod()
    		{
    			try
    			{
    				MessageBox.Show("Method Called");
    			}
    			catch (Exception ex)
    			{
    				MessageBox.Show(ex.ToString());
    			}
    		}
    	}
    

    Hope that solves your problem.  Best of luck to you!

    ~Christine


    P.S.  I've also learned that if I use "CallMethodAction" ... the method needs to be public.  So check that as well if the TargetObject solution doesn't help.
    Tuesday, November 15, 2011 4:31 AM
  • Thank you very much for your replay, I have tried the way you suggested but it also doesn't work. Finally i used Expression Blend to open this solution file, it changed my solution file automatically. I compared my solution file and found it resorted all items in solution file, all the folder items are listed before project items. Like this:

    before:

    Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Resources", "..\SourceCode\Client\LocalizeResources\Resources.csproj", "{F3355566-1879-4FA4-B3EC-9F10098093E1}"
    EndProject
    Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{09A13272-275F-4E38-ABB6-104BFA14BEA7}"
    EndProject

    after:

    Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{09A13272-275F-4E38-ABB6-104BFA14BEA7}"
    EndProject

    Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Resources", "..\SourceCode\Client\LocalizeResources\Resources.csproj", "{F3355566-1879-4FA4-B3EC-9F10098093E1}"
    EndProject

    After modified the solution file i found the exception disappeared. I don't know if this is the root cause of that exception but it solved my problem. So lucky (^_^) !!

    • Proposed as answer by Brian Hilstrom Wednesday, November 16, 2011 1:54 PM
    Wednesday, November 16, 2011 1:22 PM