首页 新闻 会员 周边 捐助

Silverlight Slider 控件 莫名奇妙 报错

0
悬赏园豆:5 [已解决问题] 解决于 2008-08-27 21:25
<DIV class=cnblogs_code>当在xaml文件中设置Value值之后,编译解决方案后 预览时会报错!~~<BR>具体代码如下:<BR>Page.xaml<BR></DIV> <DIV class=cnblogs_code><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">UserControl&nbsp;</SPAN><SPAN style="COLOR: #ff0000">x:Class</SPAN><SPAN style="COLOR: #0000ff">="SliderMaxValueTest.Page"</SPAN><SPAN style="COLOR: #ff0000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #ff0000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;xmlns</SPAN><SPAN style="COLOR: #0000ff">="http://schemas.microsoft.com/winfx/2006/xaml/presentation"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #ff0000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;xmlns:x</SPAN><SPAN style="COLOR: #0000ff">="http://schemas.microsoft.com/winfx/2006/xaml"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #ff0000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;Width</SPAN><SPAN style="COLOR: #0000ff">="400"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;Height</SPAN><SPAN style="COLOR: #0000ff">="300"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">Grid&nbsp;</SPAN><SPAN style="COLOR: #ff0000">x:Name</SPAN><SPAN style="COLOR: #0000ff">="LayoutRoot"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;Background</SPAN><SPAN style="COLOR: #0000ff">="White"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;ShowGridLines</SPAN><SPAN style="COLOR: #0000ff">="True"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">Grid.RowDefinitions</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">RowDefinition&nbsp;</SPAN><SPAN style="COLOR: #ff0000">Height</SPAN><SPAN style="COLOR: #0000ff">="150"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">RowDefinition&nbsp;</SPAN><SPAN style="COLOR: #ff0000">Height</SPAN><SPAN style="COLOR: #0000ff">="*"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">Grid.RowDefinitions</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">Slider&nbsp;</SPAN><SPAN style="COLOR: #ff0000">Maximum</SPAN><SPAN style="COLOR: #0000ff">="255"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;Minimum</SPAN><SPAN style="COLOR: #0000ff">="0"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;Value</SPAN><SPAN style="COLOR: #0000ff">="100.0"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;Grid.Row</SPAN><SPAN style="COLOR: #0000ff">="0"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;x:Name</SPAN><SPAN style="COLOR: #0000ff">="sld"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;Orientation</SPAN><SPAN style="COLOR: #0000ff">="Vertical"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;MaxHeight</SPAN><SPAN style="COLOR: #0000ff">="300"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;ValueChanged</SPAN><SPAN style="COLOR: #0000ff">="Slider_ValueChanged"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">TextBlock&nbsp;</SPAN><SPAN style="COLOR: #ff0000">x:Name</SPAN><SPAN style="COLOR: #0000ff">="Val"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;Grid.Row</SPAN><SPAN style="COLOR: #0000ff">="1"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;Width</SPAN><SPAN style="COLOR: #0000ff">="200"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">Grid</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">UserControl</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV> <DIV class=cnblogs_code><SPAN style="COLOR: #0000ff">&nbsp;</SPAN></DIV> <DIV class=cnblogs_code><SPAN style="COLOR: #0000ff">Page.xaml.cs<BR> <DIV class=cnblogs_code> <DIV class=cnblogs_code><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">namespace</SPAN><SPAN style="COLOR: #000000">&nbsp;SliderMaxValueTest<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_29_330_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_29_330_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_29_330_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_29_330_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_29_330_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_29_330_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_29_330_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_29_330_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_29_330_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_29_330_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">partial</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;Page&nbsp;:&nbsp;UserControl<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_79_328_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_79_328_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_79_328_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_79_328_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_79_328_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_79_328_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_79_328_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_79_328_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_79_328_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_79_328_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;Page()<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_111_157_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_111_157_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_111_157_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_111_157_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_111_157_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_111_157_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_111_157_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_111_157_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_111_157_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_111_157_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InitializeComponent();<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;Slider_ValueChanged(</SPAN><SPAN style="COLOR: #0000ff">object</SPAN><SPAN style="COLOR: #000000">&nbsp;sender,&nbsp;RoutedPropertyChangedEventArgs</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">double</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;e)<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_265_322_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_265_322_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_265_322_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_265_322_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_265_322_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_265_322_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_265_322_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_265_322_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_265_322_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_265_322_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Val.Text&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;e.NewValue.ToString();<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV> <DIV class=cnblogs_code><SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN></SPAN></DIV> <DIV class=cnblogs_code><SPAN><SPAN style="COLOR: #000000">预览测试网页文件时报错:<BR>Microsoft JScript runtime error: Unhandled Error in Silverlight 2 <FONT color=#ff0000>Application AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 10 Position: 157]</FONT>&nbsp;&nbsp; at System.Windows.Application.LoadComponent(Object component, Uri xamlUri)<BR>&nbsp;&nbsp; at SliderMaxValueTest.Page.InitializeComponent()<BR>&nbsp;&nbsp; at SliderMaxValueTest.Page..ctor()<BR>&nbsp;&nbsp; at SliderMaxValueTest.App.Application_Startup(Object sender, StartupEventArgs e)<BR>&nbsp;&nbsp; at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)<BR>&nbsp;&nbsp; at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)<BR><BR>如果不设置 Slider 控件的Value值时,就很正常!<BR><BR>很是纳闷,哪位朋友帮我看下错哪了?难道是Silverlight版本问题?</SPAN></SPAN></DIV><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--></DIV></SPAN></DIV>
fochan的主页 fochan | 初学一级 | 园豆:195
提问于:2008-08-27 20:16
< >
分享
最佳答案
0
在Silverlight 2 Beta 2中,如果定义了ValueChanged,似乎不能给Slider的value属性在Xaml中赋初值,可能是一个Bug。 你可以在Page的构造函数中: public Page() { InitializeComponent(); this.sld.Value = 100; } 或者在Page_Loaded事件中赋初值: void Page_Loaded(object sender, RoutedEventArgs e) { this.sld.Value = 100; }
TerryLee | 老鸟四级 |园豆:3300 | 2008-08-27 20:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册