.net - While I am filling combobox with observable collection from wcf service i am getting following Exception -
while trying fill combobox observable collection consumed wcf service getting following exception.can please me
cannot create instance of 'mainwindow' defined in assembly 'schoolmanagementsystem, version=1.0.0.0, culture=neutral, publickeytoken=null'. exception has been thrown target of invocation. error in markup file 'mainwindow.xaml' line 1 position 9.
mainwindow.xaml.cs:
public partial class mainwindow : window { public mainwindow() { initializecomponent(); servicereference1.service1client classlist = new servicereference1.service1client(); observablecollection<classdo> objclasslist = new observablecollection<classdo>(classlist.getclasslist()); // cmbclass.itemssource = objclasslist; // cmbclass.displaymemberpath = "classid"; //cmbclass.selectedvaluepath = "classname"; } }
mainwindow.xaml
<window x:class="schoolmanagementsystem.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="549" width="668" loaded="window_loaded"> <grid height="550" width="600" background="beige" > <!--textblock heading --> <textblock height="23" horizontalalignment="left" margin="10,5,0,0" name="textblockheading" text="registration: " verticalalignment="top" width="110" fontsize="17" > </textblock> <!--button , styling of login--> <button margin="451,5,12,288" content="login" cursor="hand" > <button.template> <controltemplate targettype="button"> <textblock textdecorations="underline"> <contentpresenter /> </textblock> </controltemplate> </button.template> <button.style> <style targettype="button"> <setter property="foreground" value="black"></setter> <style.triggers> <trigger property="ismouseover" value="true"> <setter property="foreground" value="red"></setter> </trigger> </style.triggers> </style> </button.style> </button> <!--end of buttonstyling , link button--> <grid margin="31,0,29,23" background="white" verticalalignment="center"> <grid.rowdefinitions> <rowdefinition height="294"></rowdefinition> </grid.rowdefinitions> <textblock height="20" horizontalalignment="left" margin="67,0,0,0" x:name="errormessage" verticalalignment="top" width="247" opacitymask="crimson" foreground="#ffe5572c"></textblock> <textblock height="23" horizontalalignment="left" margin="67,20,0,0" name="textblockstudentcode" text="studentcode" verticalalignment="top" width="110"></textblock> <textblock height="23" horizontalalignment="left" margin="67,50,0,0" name="textblockfullname" text="fullname" verticalalignment="top" width="110"></textblock> <textblock height="23" horizontalalignment="left" margin="67,80,0,0" name="textblockfathername" text="fathername" verticalalignment="top" width="110"></textblock> <textblock height="23" horizontalalignment="left" margin="67,110,0,0" name="textblockaddress" text="address" verticalalignment="top" width="110"></textblock> <textblock height="23" horizontalalignment="left" margin="67,140,0,0" name="textblockmobno" text="mobile no" verticalalignment="top" width="110"></textblock> <textblock height="23" horizontalalignment="left" margin="67,170,0,0" name="textblockemail" text="email" verticalalignment="top" width="110"></textblock> <textblock height="23" horizontalalignment="left" margin="67,200,0,0" name="textblockclass" text="class" verticalalignment="top" width="110"></textblock> <textblock height="23" horizontalalignment="left" margin="67,230,0,0" name="textblocksection" text="section" verticalalignment="top" width="110"></textblock> <textbox height="23" horizontalalignment="left" margin="183,20,0,0" name="textboxstudentcode" verticalalignment="top" width="222"></textbox> <textbox height="23" horizontalalignment="left" margin="183,50,0,0" name="textboxfullname" verticalalignment="top" width="222"></textbox> <textbox height="23" horizontalalignment="left" margin="183,80,0,0" name="textboxfathername" verticalalignment="top" width="222"></textbox> <textbox height="23" horizontalalignment="left" margin="183,110,0,0" name="textboxaddress" verticalalignment="top" width="222"></textbox> <textbox height="23" horizontalalignment="left" margin="183,140,0,2" name="textboxmobno" verticalalignment="top" width="222"></textbox> <textbox height="23" horizontalalignment="left" margin="183,170,0,2" name="textboxemail" verticalalignment="top" width="222"></textbox> <combobox x:name="cmbclass" itemssource="{binding}" verticalalignment="top" displaymemberpath="classname" selectedvaluepath="classid"/> <textbox height="23" horizontalalignment="left" margin="183,230,0,2" name="textboxsection" verticalalignment="top" width="222"></textbox> <button content="submit" height="23" horizontalalignment="left" margin="183,264,0,0" name="submit" verticalalignment="top" width="70" click="submit_click" /> <button content="reset" height="23" horizontalalignment="left" margin="259,264,0,0" name="button2" verticalalignment="top" width="70" /> <button content="cancel" height="23" horizontalalignment="right" margin="0,264,60,0" name="button3" verticalalignment="top" width="70" /> </grid> </grid> </window>
any appreciated
if want make more debuggable, move lines out of constructor , window_loaded
handler (its in xaml, didn't include in .cs).
servicereference1.service1client classlist = new servicereference1.service1client(); observablecollection<classdo> objclasslist = new observablecollection<classdo> classlist.getclasslist()); //<-- line compile? // cmbclass.itemssource = objclasslist; // cmbclass.displaymemberpath = "classid"; //cmbclass.selectedvaluepath = "classname";
your binding won't pick them unless implement inotifypropertychanged
can them working , move them constructor later (or better refactor method , call loaded or constructor necessary).
Comments
Post a Comment