Click here to Skip to main content
11,720,785 members (78,588 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Silverlight
Error:
An UnHandled exception('Unhandled Error in Silverlight Application (Code: 4004)
Category: ManagedRuntimeError
Message: System.Windows.Markup.XamlParseException: [Line: 0 Position:0]---> System.ArgumentNullExecption: Value Cannot be Null.)
XAML:-
<ComboBox Width="100" SelectedItem="SUPPLIER" ItemsSource="{Binding}" Height="22"  HorizontalAlignment="Center" Margin="0,0,2,0"  Name="cmbsup" VerticalAlignment="Bottom"  >
                       <ComboBox.ItemTemplate>
                           <DataTemplate>
                               <StackPanel Orientation="Horizontal">
                                   <CheckBox IsChecked="{Binding IsSelected,Mode=TwoWay}" Content="{Binding Name}" x:Name="chk" Click="chk_Click"></CheckBox>
                               </StackPanel>
                           </DataTemplate>
                       </ComboBox.ItemTemplate>
                   </ComboBox>
<ComboBox Width="100" Height="22"  HorizontalAlignment="Center" Margin="0,0,2,0" Name="cmbyr" VerticalAlignment="Bottom" >
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <CheckBox IsChecked="{Binding IsYear,Mode=TwoWay}" Content="{Binding Year}" x:Name="chk1" Click="chk1_Click"></CheckBox>
                                </StackPanel>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
CODE:-
void t2_GetPurComboCompleted(object sender, DaService.GetPurComboCompletedEventArgs e)
        {
 
            PagedCollectionView p = new PagedCollectionView(e.Result);
            cmbprod.Items.Add("PRODUCT");
            foreach (string k in e.Result.AsEnumerable().Select(g => g.PROD_TYPE).Distinct())
            {
                cmbprod.Items.Add(k);
            }
            cmbprod.SelectedIndex = 0;
 
            foreach (string k in e.Result.AsEnumerable().Select(g => g.YEAR).Distinct())
            {
                dt.Add(new data { Year = k, IsYear = false });
            }
            cmbyr.ItemsSource = dt;
            cmbpmon.Items.Add("MONTH");
            foreach (string k in e.Result.AsEnumerable().Select(g => g.MONTH).Distinct())
            {
                cmbpmon.Items.Add(k);
            }
            cmbpmon.SelectedIndex = 0;
            cmbpotyp.Items.Add("POTYPE");
            foreach (int k in e.Result.AsEnumerable().Select(g => g.PO_TYP).Distinct())
            {
                cmbpotyp.Items.Add(k);
            }
            cmbpotyp.SelectedIndex = 0;
            cmbbuyer.Items.Add("BUYER");
            foreach (string k in e.Result.AsEnumerable().Select(g => g.Buyer).Distinct())
            {
                cmbbuyer.Items.Add(k);
            }
            cmbbuyer.SelectedIndex = 0;
 

            foreach (string k in e.Result.AsEnumerable().Select(g => g.Sup_Name).Distinct())
            {
                dt.Add(new data { Name=k,IsSelected=false});
            }
 
            cmbsup.ItemsSource = dt;
            cmbposubtyp.Items.Add("POSUBTYPE");
 
            ReadDataFromDatabase();
        }
 
     private void chk_Click(object sender, RoutedEventArgs e)
        {
            List<data> dt = (List<data>)cmbsup.ItemsSource;
            string ddd = "";
            foreach (data d in dt)
            {
                if ((bool)d.IsSelected)
                {
                    ddd += ",'" + d.Name + "'";
                }
            }
            if(ddd!="")
            ddd = ddd.Substring(1);
            supp = ddd;
            timer(); 
            ReadDataFromDatabase();
        }
 
        private void chk1_Click(object sender, RoutedEventArgs e)
        {
            List<data> dt1 = (List<data>)cmbyr.ItemsSource;
            string ddd = "";
            foreach (data d in dt1)
            {
                if ((bool)d.IsSelected)
                {
                    ddd += ",'" + d.Name + "'";
                }
            }
            if (ddd != "")
                ddd = ddd.Substring(1);
            supp = ddd;
            timer();
            ReadDataFromDatabase();
        }
public class data
    {
       private string Sup_name;
        private bool? isSelected;
        private string Yr_name;
        private bool? isyear;
 
        public data() { }
 
        public string Name
        {
            get { return Sup_name; }
            set
            {
                Sup_name = value;
 
                NotifyPropertyChanged(&quot;Name&quot;);
            }
        }
 
        public bool? IsSelected
        {
            get { return isSelected; }
            set
            {
                isSelected = value;
                NotifyPropertyChanged(&quot;IsSelected&quot;);
            }
        }
        public string Year
        {
            get { return Yr_name; }
            set
            {
                Yr_name = value;
 
                NotifyPropertyChanged(&quot;Year&quot;);
            }
        }
 
        public bool? IsYear
        {
            get { return isyear; }
            set
            {
                isyear = value;
                NotifyPropertyChanged(&quot;IsYear&quot;);
            }
        }
 
        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;
 
        private void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
 
        #endregion
    }
Posted 1-Aug-12 0:04am
Edited 1-Aug-12 0:10am
v2
Comments
Kenneth Haugland at 1-Aug-12 6:30am
   
It says you got an error in the first line in your XAML, so you are proberbly missing some dll or something strange has happened.
Kenneth Haugland at 1-Aug-12 6:32am
   
But it seems you error could happene anywhere:
http://forums.silverlight.net/t/230420.aspx

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This is basically one of the least informative errors you can get, as the actual mistake could be anywere. See the link I posted in the comment section.

The best ting I could propose is to rewrite the code (or copy and paste) step by step to find out exactly were your problem is. So good luck to you Smile | :)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 2,179
1 OriginalGriff 924
2 F-ES Sitecore 640
3 Maciej Los 609
4 Richard MacCutchan 540


Advertise | Privacy | Mobile
Web01 | 2.8.150901.1 | Last Updated 1 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100