none
The invocation of the constructor on type 'WpfApplication1.MainWindow' that matches the specified binding constraints threw an exception.

    Question


  •                     

    <Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
             xmlns:core="clr-namespace:System;assembly=mscorlib" 
            xmlns:local="clr-namespace:WpfApplication1"
             xmlns:my="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit" 
            xmlns:localprimitives="clr-namespace:Microsoft.Windows.Controls.Primitives;assembly=WPFToolkit"    
            Title="MainWindow" Height="350" Width="525">
        <Window.Resources>
            <ObjectDataProvider x:Key="RecordValues" MethodName="GetValues"
                                ObjectType="{x:Type core:Enum}">
                <ObjectDataProvider.MethodParameters>
                    <x:Type Type="local:RecordValues" />
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>
        </Window.Resources>
        <Grid>
            <dg:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding}"
                      Margin="10" Name="dataGrid1">
                <dg:DataGrid.Columns>
                    <dg:DataGridComboBoxColumn Header="Combo" Width="300"
                         SelectedItemBinding="{Binding Value}" 
                         ItemsSource="{Binding Source={StaticResource RecordValues}}" />



                </dg:DataGrid.Columns>
            </dg:DataGrid>
        </Grid>

    </Window>

    this is the error while debugging the above  code:"The invocation of the constructor on type 'WpfApplication1.MainWindow' that matches the specified binding constraints threw an exception.' Line number '8' and line position '9'."

    since the beginning of the project I am  using  xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit" . so I can't remove this namespace and opt for DataGrid instead of dg:DataGrid. I know that the problem relies on the usage of the abobe namespace. anybody can help to resolve the issues at the same time retaining dg:

    thanks in advance 

    Iqbal



    itismeiqbal

    Tuesday, February 14, 2012 2:21 PM

Answers

  • Hi iqbal

    Firstly, you no longer need the toolkit for the Datagrid, since .net 4 it was included, so you can drop the namespace declaration completely for that control.

    Secondly, I believe that error relates to the code-behind constructor, not the xaml.

    Try wrapping your code in a try/catch to find the problem:

            public MainWindow()
            {
                try
                {
                    InitializeComponent();
                }
                catch (Exception exc)
                {
                    MessageBox.Show("1. " + exc.Message);
                }
                try
                {
                    //The rest of your constructor code
                }
                catch (Exception exc)
                {
                    MessageBox.Show("2. " + exc.Message);
                } 
            }
    Regards,

    Pedro


    If you find my post helpful, please remember to "Mark As Answer" and/or "Vote as Helpful"

    Tuesday, February 14, 2012 3:20 PM
  • Hi iqbal1980,

    As Pedro mentioned above, if you are using .NET Framework 4, you can just remove "dg:" thing in your code.

    To find the root cause of your original problem, you can click the "View Detail" link at the bottom when an exception occurs to see more detailed informations about the error, and you can click the "Copy exception detail to Clipboard" link and paste the exception detail in your forum post which will help us to resolve your problem.

    In that case, the inner expection might tell us what was wrong.

    Best regards,


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, February 16, 2012 7:25 AM

All replies

  • Hi iqbal

    Firstly, you no longer need the toolkit for the Datagrid, since .net 4 it was included, so you can drop the namespace declaration completely for that control.

    Secondly, I believe that error relates to the code-behind constructor, not the xaml.

    Try wrapping your code in a try/catch to find the problem:

            public MainWindow()
            {
                try
                {
                    InitializeComponent();
                }
                catch (Exception exc)
                {
                    MessageBox.Show("1. " + exc.Message);
                }
                try
                {
                    //The rest of your constructor code
                }
                catch (Exception exc)
                {
                    MessageBox.Show("2. " + exc.Message);
                } 
            }
    Regards,

    Pedro


    If you find my post helpful, please remember to "Mark As Answer" and/or "Vote as Helpful"

    Tuesday, February 14, 2012 3:20 PM
  • it shows XAML Parse Exception was unhandled 

    itismeiqbal

    Tuesday, February 14, 2012 3:46 PM
  • without dg: ie only with DataGrid there is no problem . 

    itismeiqbal

    Tuesday, February 14, 2012 3:53 PM
  • Hi,

    Is it happening in your development PC or in some other machine? Just make sure that you have all assemblies with their dependent assemblies.

    /Srinivas

    Tuesday, February 14, 2012 4:13 PM
  • in my development PC only . what are the necessery assemblies ad dependent assemblies in this particular case

    itismeiqbal

    Tuesday, February 14, 2012 4:24 PM
  • Hey this exception most likely to happen when you rename the window or the namespace of the window. Please make sure the namespace and the class name are the same in the XAML and on the code behind file.


    Your XAML reads...


    <Window x:Class="WpfApplication1.MainWindow"


    therefore the code behind file should look like this.


    namespace WpfApplication1
    {


     Public class MainWindow : Window
    {




    Hope it helps!!!

    Regards Vallarasu S. FSharpMe.blogspot.com

    Tuesday, February 14, 2012 5:24 PM
  • it is just similaras u told

    when i use DataGrid no problem at all. when I use dg:DataGrid the error  occurs


    itismeiqbal

    Tuesday, February 14, 2012 5:33 PM
  • Hi iqbal1980,

    As Pedro mentioned above, if you are using .NET Framework 4, you can just remove "dg:" thing in your code.

    To find the root cause of your original problem, you can click the "View Detail" link at the bottom when an exception occurs to see more detailed informations about the error, and you can click the "Copy exception detail to Clipboard" link and paste the exception detail in your forum post which will help us to resolve your problem.

    In that case, the inner expection might tell us what was wrong.

    Best regards,


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, February 16, 2012 7:25 AM
  • Hi iqbal1980,

    I am closing this thread as answered. If you have any further questions, please feel free to post back.

    Have a nice day!


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, February 21, 2012 5:50 AM