issue with Namespace when trying to convert
issue namespace when trying convert . says line problem xmlns:myr="clr-namespace:playcards"
any ideas ?
heres code
<window x:class="playcards.cardgame" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:myr="clr-namespace:playcards" title="playcards" minheight="300" minwidth="200"> <window.resources> <myr:convertdoublestring x:key="dblstrconverter"/> </window.resources> <grid> <grid.rowdefinitions> <rowdefinition height="*" /> <rowdefinition height="3*" /> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="*"></columndefinition> <columndefinition width="2*"></columndefinition> <columndefinition width="*"></columndefinition> </grid.columndefinitions> <dockpanel grid.row="0" grid.columnspan="3"> <menu dockpanel.dock="top"> <menuitem header="_cards"> <menuitem header="_deal"></menuitem> </menuitem> </menu> <stackpanel background="ghostwhite" orientation="horizontal"> <label margin="3" verticalalignment="center">card no.</label> <textbox margin="3,10" verticalalignment="center" x:name="txtcardno" width="30"> <textbox.text> <binding elementname="slcardno" path="value" converter="{staticresource dblstrconverter}"/> </textbox.text> </textbox> <slider x:name="slcardno" value="{binding elementname=txtcardno, path=content, converter={staticresource dblstrconverter}}" margin="3,10" verticalalignment="center" minwidth="80" maximum="52" minimum="1" valuechanged="slider_valuechanged"> <!--<slider.value> <binding elementname="txtcardno" path="content" converter="{staticresource dblstrconverter}"/> </slider.value>--> </slider> </stackpanel> </dockpanel> <rectangle grid.row="2" grid.columnspan="1" fill="beige" stroke="burlywood"></rectangle> <rectangle grid.row="2" grid.column="2" grid.columnspan="1" fill="aquamarine" stroke="burlywood"></rectangle> <grid grid.row="2" grid.column="1" > <grid.rowdefinitions> <rowdefinition height="*"></rowdefinition> <rowdefinition height="2*"></rowdefinition> <rowdefinition height="*"></rowdefinition> </grid.rowdefinitions> <image x:name="cardsuitsymbol" horizontalalignment="left" source="images\spades.jpg" height="30" grid.rowspan="2" verticalalignment="top"></image> <textblock verticalalignment="center" margin="0,0,5,0" horizontalalignment="right" fontsize="22" grid.row="2">three</textblock> </grid> </grid> </window> //.cs 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; namespace playcards { /// <summary> /// interaction logic window1.xaml /// </summary> public partial class cardgame : window { public cardgame() { initializecomponent(); card.shortcard = true; deck mycards = new deck(); //this.cardsuitsymbol.source=new bitmapimage(new uri("images/diamonds.jpg",urikind.relative)); for (int = 0; < 52; i++) { //txtcards.text += string.format("card {0} {1}\r\n", + 1, mycards[i]); //console.writeline("card {0} {1}", + 1, mycards[i]); } if (card.shortcard) { card c = mycards["2d"]; } //console.readkey(); } private void slider_valuechanged(object sender, routedpropertychangedeventargs<double> e) { } } } ///class using system; using system.collections.generic; using system.linq; using system.text; namespace playcards { public class card { public enum cardvalue { two, three, four, five, six, seven, eight, nine, ten, jack, queen, king, ace }; public enum cardsuit { hearts, clubs, diamonds, spades }; public static char[] suitchars = new char[4] { 'h', 'c', 'd', 's' }; public static char[] suitvalues = new char[13] { '2', '3', '4', '5', '6', '7', '8', '9', 't', 'j', 'q', 'k', 'a' }; public static bool shortcard=false; public cardvalue value{get;set;} public cardsuit suit{get;set;} public override string tostring() { if (shortcard) return suitvalues[(int)(value)].tostring() + suitchars[(int)suit]; else return value.tostring()+' '+suit.tostring(); } public object convert(object value, type targettype, object parameter, cultureinfo culture) { string ret = math.truncate((double)value).tostring(); return ret; } public object convertback(object value, type targettype, object parameter, cultureinfo culture) { return system.convert.todouble(value.tostring()); } } // end class } // end ns
your custom declaration appears missing assembly reference.
xmlns:custom="clr-namespace:numericupdowncustomcontrol;assembly=customlibrary"
please refer link.
http://msdn.microsoft.com/en-us/library/ms752059.aspx#custom_prefixes_and_custom_types_in_xaml
rudy =8^d
mark best replies answers. "fooling computers since 1971."
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment