[UWP] [Xaml] XAML中的基础知识 [英] [UWP][Xaml]Basics in XAML

查看:74
本文介绍了[UWP] [Xaml] XAML中的基础知识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hola,



   我希望我已经发布在正确的论坛上。如果我在错误的论坛,请告诉我。

Hola,

    I hope i have posted in the right forum. if i'm in the wrong forum, please let me know.

   我正在学习用C#构建一个App。我是高级语言编程的新手。所以我在这里有几个问题对你们所有人来说似乎都很简陋。但是我希望我可以从错误中吸取教训并继续发挥作用。 



1.我使用以下网站构建基本应用程序。



docs.microsoft.com/en-us/windows/uwp/get-started/create-a-hello-world-app-xaml-universal


    I'm learning to build an App in C#. I'm new to programming in high level languages. So i have a couple of questions here that might seem rudimentary to all of you out there. But i'm hoping i can learn from my mistakes and build on. 

1. I used the following website to build a basic App.

docs.microsoft.com/en-us/windows/uwp/get-started/create-a-hello-world-app-xaml-universal

完成应用程序后,我在代码"TableData.cs"中添加了一个类。

After I completed the App, I added a class to the code "TableData.cs"

namespace HelloWorld
{

    class TableData
    {
        public int[] Row;

        public int[] Column;
    }
}

我重命名为"Hello World"按钮"创建表格"。



I renamed the "Hello World" button to "Create Table".

    <Grid>
        <Button x:Name="button" Content="Create Table" HorizontalAlignment="Left" Margin="558,402,0,0" VerticalAlignment="Top" RenderTransformOrigin="2.188,1.473" Click="Button_Click"/>
        <StackPanel Orientation="Horizontal">
            <Button Content ="Add Row" Margin ="300" Click="Button_Click1" />
            <Button Content ="Add Column" Margin ="0" Click="Button_Click2" />
        </StackPanel>
    </Grid>

我还添加了另外两个名为"Row"的按钮。我希望当用户点击"创建表格"按钮时,将创建一个包含5行和5列的随机表,并使用值0初始化。我为此添加了"列"和"列"。代码到clickbutton。

I also added two other buttons called "Row" and "Column"
i am hoping that when a user clicks on the Create Table button, a random table of 5 rows and 5 columns will be created and initialized with the values 0. For which i added the code to the clickbutton.

        private async void Button_Click(object sender, RoutedEventArgs e)
        {

            List<TableData> TableOne = new List<TableData>();
            int[] numbers = { 1, 2, 3, 4, 5 };

            for(int i=1; i<numbers.Length;i++)
            {
                TableOne.Add(new TableData());
                TableOne[i].Column[i] = 0;
                TableOne[i].Row[i] = 0;
            }

            MediaElement mediaElement = new MediaElement();
            var synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();
            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Hello, World!");
            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();
        }

 上面代码段中的"For循环"意味着将5行和0列添加到表。但我认为我的实现是错误的,因为在'for'循环中调试第二行时代码退出了我。我想学习使用Classes&
在这个结构中列出,这就是我按照我的方式行事的原因。

 The 'For Loop' in the above snippet is meant to added 5 rows and columns of 0's to the table. But i think my implementation is wrong, because the code quits on me when debugging the second line in the 'for' loop. I want to learn to use Classes & List in this structure, which is why i did the way i did.

2。我如何访问列表"表一"。当我跳到第二个按钮。当我在"添加行"中加载时,如何加载Tableone? &安培; "添加列"按钮。

2. how can i access the list "Table one" when i jump to the second button. How do i load the Tableone when im in the "Add Row" & "Add Column" button.

谢谢。

M

thank you.
M

推荐答案

C#集合索引是基于0的(与VB6上基于1的索引相反),所以第一个元素是TableOne是TableOne [0]。

C# collection index is 0 based (contrary to 1-based index on VB6), so the first element is TableOne is TableOne[0].

你想要修复开始号码"i"。

You'll want to fix the start number of "i".


这篇关于[UWP] [Xaml] XAML中的基础知识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆