Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ';System.Windows.Controls.Grid';不包含';setRow&x27;WP 8项目_C#_Windows Phone 8 - Fatal编程技术网

C# ';System.Windows.Controls.Grid';不包含';setRow&x27;WP 8项目

C# ';System.Windows.Controls.Grid';不包含';setRow&x27;WP 8项目,c#,windows-phone-8,C#,Windows Phone 8,我正在尝试为Windows8手机制作一个密码拼图。 .net框架是4.5 我遇到以下错误:“System.Windows.Controls.Grid”在Grid.setRow(txt,x)中不包含“setRow”的定义;我想动态创建文本框,而不使用XAML 据我所知,Windows.Controls.Grid有一个静态方法Grid.setRow(UIelement,int) 这里是MainPage.xaml.cs using System; using System.Collections.Ge

我正在尝试为Windows8手机制作一个密码拼图。 .net框架是4.5

我遇到以下错误:“System.Windows.Controls.Grid”在Grid.setRow(txt,x)中不包含“setRow”的定义;我想动态创建文本框,而不使用XAML

据我所知,Windows.Controls.Grid有一个静态方法Grid.setRow(UIelement,int)

这里是MainPage.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Phone.Controls;
using System.Windows.Resources;
using System.IO;

namespace CryptogramPuzzle
{
public partial class MainPage : PhoneApplicationPage
{
    List<string> quotes;
    List<TextBox> tb;
    int length = 0;
    int width;
    int height;
    // Constructor
    public MainPage()
    {
        InitializeComponent();

        Random r = new Random();
        string encodedStr;

        InitializeComponent();

        getQuotes();
        int rInt = r.Next(0, quotes.Count()); //generates random index for a quote selection
        encodedStr = Encryption.encode(quotes[rInt]);
        length = encodedStr.Length;
        createTxtBox(0, 0);
    }

    /// <summary>
    /// Loads quotes from the text file
    /// </summary>
    public void getQuotes()
    {
        quotes = new List<string>();
        try
        {
            StreamResourceInfo sInfo = Application.GetResourceStream(new Uri("/CryptogramPuzzle;component/Resources/Puzzles.txt", UriKind.Relative));
            StreamReader sr = new StreamReader(sInfo.Stream);//feeds the reader with the stream
            string line;
            while ((line = sr.ReadLine()) != null)
            {
                quotes.Add(line);
            }
            sr.Close();
            // System.Console.WriteLine(quotes[0]);

        }
        catch (Exception e)
        {
            throw (e);
        }
    }

    public void createTxtBox(int x, int y)
    {
        TextBox txt = new TextBox();
        RowDefinition newRow = new RowDefinition();
        newRow.Height = new GridLength(0, GridUnitType.Auto);
        ContentPanel.RowDefinitions.Add(newRow);
        txt.MinHeight = 10;
        txt.MinHeight = 10;
        ContentPanel.Children.Add(txt);
        Grid.setRow(txt, x);

    }


}
 }
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Windows;
使用System.Windows.Controls;
使用Microsoft.Phone.Controls;
使用System.Windows.Resources;
使用System.IO;
命名空间加密模糊
{
公共部分类主页:PhoneApplicationPage
{
列出报价;
列出结核病;
整数长度=0;
整数宽度;
内部高度;
//建造师
公共主页()
{
初始化组件();
随机r=新随机();
字符串编码器;
初始化组件();
getQuotes();
int rInt=r.Next(0,quotes.Count());//为引号选择生成随机索引
encodedStr=Encryption.encode(引号[rInt]);
长度=编码器。长度;
createTxtBox(0,0);
}
/// 
///从文本文件加载引号
/// 
public void getQuotes()
{
quotes=新列表();
尝试
{
StreamResourceInfo=Application.GetResourceStream(新Uri(“/CryptogramPuzzle;component/Resources/Puzzles.txt”,UriKind.Relative));
StreamReader sr=newstreamreader(sInfo.Stream);//为读取器提供流
弦线;
而((line=sr.ReadLine())!=null)
{
引号。添加(行);
}
高级关闭();
//System.Console.WriteLine(引号[0]);
}
捕获(例外e)
{
投掷(e);
}
}
public void createTxtBox(int x,int y)
{
TextBox txt=新的TextBox();
RowDefinition newRow=新的RowDefinition();
newRow.Height=新的GridLength(0,GridUnitType.Auto);
ContentPanel.RowDefinitions.Add(newRow);
txt.MinHeight=10;
txt.MinHeight=10;
ContentPanel.Children.Add(txt);
Grid.setRow(txt,x);
}
}
}
这是我的主页。xaml

<phone:PhoneApplicationPage
x:Class="CryptogramPuzzle.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!-- LOCALIZATION NOTE:
        To localize the displayed strings copy their values to appropriately named
        keys in the app's neutral language resource file (AppResources.resx) then
        replace the hard-coded text value between the attributes' quotation marks
        with the binding clause whose path points to that string name.

        For example:

            Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"

        This binding points to the template's string resource named "ApplicationTitle".

        Adding supported languages in the Project Properties tab will create a
        new resx file per language that can carry the translated values of your
        UI strings. The binding in these examples will cause the value of the
        attributes to be drawn from the .resx file that matches the
        CurrentUICulture of the app at run time.
     -->

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
        <TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

    </Grid>

    <!--Uncomment to see an alignment grid to help ensure your controls are
        aligned on common boundaries.  The image has a top margin of -32px to
        account for the System Tray. Set this to 0 (or remove the margin altogether)
        if the System Tray is hidden.

        Before shipping remove this XAML and the image itself.-->
    <!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />-->
</Grid>

请帮我纠正这个错误,让我变得非常绝望!
谢谢。

如果它是一个标准的框架方法,我很确定标准的Pascal大小写规则(至少)规定它将被称为
SetRow
,而不是
SetRow