首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Windows Mobile >

关于XamlParseException的错误

2013-03-21 
关于XamlParseException的异常System.Windows.Markup.XamlParseException occurredMessageFailed to assi

关于XamlParseException的异常
System.Windows.Markup.XamlParseException occurred
  Message=Failed to assign to property 'System.Windows.Controls.Primitives.ButtonBase.Click'. [Line: 39 Position: 144]
  LineNumber=39
  LinePosition=144
  StackTrace:
       at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       at PhoneApp1.MainPage.InitializeComponent()
       at PhoneApp1.MainPage..ctor()
       at System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
       at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
       at System.Activator.InternalCreateInstance(Type type, Boolean nonPublic, StackCrawlMark& stackMark)
       at System.Activator.CreateInstance(Type type)
       at System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(AsyncCallback userCallback, PageResourceContentLoaderAsyncResult result)
       at System.Windows.Navigation.PageResourceContentLoader.<>c__DisplayClass4.<BeginLoad>b__0(Object args)
       at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
       at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
       at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
       at System.Delegate.DynamicInvokeOne(Object[] args)
       at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
       at System.Delegate.DynamicInvoke(Object[] args)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
       at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
       at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
       at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
       at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)
下面是xaml里面的内容


 <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="55"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <!--<StackPanel x:Name="TitlePanel" Margin="12,17,0,0" Grid.Row="1">
            <TextBlock x:Name="ApplicationTitle" Text="移步换影" Style="{StaticResource PhoneTextNormalStyle}" Height="29" />
        </StackPanel>-->
        <TextBlock x:Name="ApplicationTitle" Text="移步换影" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,26,12,0" />

        <Grid x:Name="ContentPanel" Background="White" Margin="12,6,2,220" Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="69*" />
                <ColumnDefinition Width="104*" />
                <ColumnDefinition Width="293*" />
            </Grid.ColumnDefinitions>
            <!--<Image Height="508" HorizontalAlignment="Left" Margin="12,6,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="442"  />-->
            <Image HorizontalAlignment="Left" Margin="8,7,0,0" Name="image1" Stretch="Fill" Width="450" Height="475" VerticalAlignment="Top" Grid.ColumnSpan="3" />
        </Grid>
        <Grid x:Name="grid1" Margin="12,512,2,12" Grid.Row="2" >
            <Button   Content="重写" Height="84" HorizontalAlignment="Left" Margin="8,95,0,0" Name="button1" VerticalAlignment="Top" Width="143" Click="button1_Click"/>
            <ListBox Height="161" Margin="286,10,26,0" Name="listBox1" VerticalAlignment="Top" SelectionChanged="listBox1_SelectionChanged" />
            <Button  Content="" Height="87" HorizontalAlignment="Left"  VerticalAlignment="Top" Width="157" Margin="0,4,0,0" Name="button2" />
            <TextBox  Height="112" HorizontalAlignment="Left" Margin="175,19,0,0" Name="textBox1" Text="TextBox" VerticalAlignment="Top" Width="86" />


            <!--<Button Content="Button" Height="72" HorizontalAlignment="Left" Margin="26,4,0,0" Name="button3" VerticalAlignment="Top" Width="160" />
             <Button Content="Button" Grid.Row="2" Height="72" HorizontalAlignment="Left" Margin="48,599,0,0" Name="button4" VerticalAlignment="Top" Width="160" />-->
        </Grid>
        <InkPresenter Background="Transparent" Name="ink" MouseLeftButtonDown="ink_MouseLeftButtonDown" MouseMove="ink_MouseMove" MouseLeftButtonUp="ink_MouseLeftButtonUp" Margin="20,13,12,225" Grid.Row="2" />
        <!--ContentPanel - place additional content here-->
    </Grid>


 
    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
                <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

</phone:PhoneApplicationPage>
[解决办法]
Click="button1_Click" 删掉,编译。
再加上去
再编译

如果不成,移除System.Windows的引用,重新添加

热点排行