小编gal*_*fan的帖子

如何使用WPF中的按钮导航到其他页面

我在名称下设置了第二个.xaml页面Page2.xaml,我希望这样做,以便在单击我的按钮时,用户被带到Page2.xaml

我的按钮位于我的内部Page1.xaml:

<Grid>
    <Button x:Name="localModeBtn" 
            Style="{StaticResource MainButtonStyle}"  
            Content="local mode" 
            Click="localModeBtn_Click" />
</Grid>
Run Code Online (Sandbox Code Playgroud)

对于按钮事件处理程序:

private void localModeBtn_Click(object sender, RoutedEventArgs e)
    {
        Uri uri = new Uri("Page2.xaml", UriKind.Relative);
        this.NavigationService.Navigate(uri);
    }
Run Code Online (Sandbox Code Playgroud)

点击按钮后,我收到一条错误,上面写着"无法找到资源page2.xaml"这个东西Page2.xaml是在同一个文件夹中,Pag1.xaml所以我看不出哪里出错了?

c# wpf xaml button

11
推荐指数
1
解决办法
5万
查看次数

用C打印出素数

我正在尝试将素数打印到从用户获得的某个值.如果我只收到1的答案,我想我的for循环有问题吗?

#include <stdio.h>
#include <cs50.h>

int main (void)
{
    printf("Length: ");
    int length = GetInt();

    bool notPrime = false;

    for (int i = 1; i < length; i++)
    {
        for (int k = 1; k <= i/2; k++)
        {
            if (i % k == 0)
            {
                notPrime = true;
                break;
            }
            else
            { 
                notPrime = false;
            }   
        }
        if (notPrime == false)
        {
            printf("%d ", i);
        }
    }
    printf("\n");
}
Run Code Online (Sandbox Code Playgroud)

c for-loop numbers cs50

-2
推荐指数
1
解决办法
211
查看次数

标签 统计

button ×1

c ×1

c# ×1

cs50 ×1

for-loop ×1

numbers ×1

wpf ×1

xaml ×1