Link to home
Start Free TrialLog in
Avatar of ANINDYA
ANINDYAFlag for India

asked on

C# application an error

Experts
In the code below I am facing this error as you can see in the picture.

Can anyone suggest me how in all the Show() ----what is the problem ?

The all the Show() functions are showing the same errors when I am clicking the button.

Thanking you


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

using AdventureWorks.WPF.Model;

namespace AdventureWorks.WPF
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        ModelDataContext DC = new ModelDataContext();
        public Window1()
        {
            InitializeComponent();

            WindowsListBox.ItemsSource = WindowViewStateManager.Instance.WindowViewStates;

        }

        private void SalesOrderButton_Click(object sender, RoutedEventArgs e)
        {
            SalesOrderWindow wnd = new SalesOrderWindow();
            
            wnd.DataContext = DC.SalesOrderHeaders;
            wnd.Show();
        }

        private void CustomerButton_Click(object sender, RoutedEventArgs e)
        {
            CustomerWindow wnd = new CustomerWindow();
            wnd.DataContext = DC.Customers;
            wnd.Show();
        }

        private void ProductButton_Click(object sender, RoutedEventArgs e)
        {
            ProductWindow wnd = new ProductWindow();
            wnd.DataContext = DC.Products;
            wnd.Show();            
        }
    }
}

Open in new window

Error.JPG
ASKER CERTIFIED SOLUTION
Avatar of Sawiner
Sawiner

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ANINDYA

ASKER

the SaelsOrderWindow.xaml and the SalesOrderController.cs class is as followes
the  code of the SalesOrderController.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AdventureWorks.WPF
{
    public class SalesOrderController
    {
        public bool CanUpdateCurrent()
        {
            return false;
        }
        public bool CanDeleteCurrent()
        {
            return false;
        }
        
    }
}


the code of the salesOrderWindow.xaml

<Window x:Class="AdventureWorks.WPF.SalesOrderWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:AdventureWorks.WPF"
    local:WindowViewState.IsManaged="True"
        MinWidth="590" Width="590"
    Title="Sales Orders" >

    <Window.CommandBindings>
        <CommandBinding 
            Command="{x:Static local:Commands.NewSalesOrder}" 
            CanExecute="NewSalesOrder_CanExecute" 
            Executed="NewSalesOrder_Executed" />
        <CommandBinding 
            Command="{x:Static local:Commands.DeleteSalesOrder}" 
            CanExecute="DeleteSalesOrder_CanExecute" 
            Executed="DeleteSalesOrder_Executed" />
        <CommandBinding 
            Command="{x:Static local:Commands.UpdateSalesOrder}" 
            CanExecute="UpdateSalesOrder_CanExecute" 
            Executed="UpdateSalesOrder_Executed" />
    </Window.CommandBindings>
    
    
    
    <local:SalesOrderView />

</Window>

Open in new window

Avatar of ANINDYA

ASKER

thanks