我正在为 Windows 小部件开发 Silverlight 小工具。当我在我的小部件中添加另一个页面时,我发现了这个错误。我在 Stack Overflow 中发现了同样的问题,但它不适用于小部件。
我的示例代码在这里 XAML 代码
<navigation:Page x:Class="SilverlightGadgetDocked.Test"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
d:DesignWidth="359" d:DesignHeight="225"
Title="Test Page">
<Grid x:Name="LayoutRoot">
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="182,103,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
</Grid>
</navigation:Page>
和cs代码在这里,
public partial class Test:UserControl
{
public Test()
{
MessageBox.Show("af");
InitializeComponent();
}
// Executes when the user navigates to this page.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private void button1_Click(object sender, RoutedEventArgs e)
{
}
}