C# XAML表格数据视图
我正在使用C#和XAML开发Windows应用商店应用程序。在下面的代码中,我在名为C# XAML表格数据视图,c#,xaml,view,C#,Xaml,View,我正在使用C#和XAML开发Windows应用商店应用程序。在下面的代码中,我在名为greetingOutput的文本块中显示数据 try { var response = navigationParameter.ToString(); var serializer = new DataContractJsonSerializer(typeof(QualityRecordsRootObject)); var stream = new MemoryStream(Encod
greetingOutput
的文本块中显示数据
try
{
var response = navigationParameter.ToString();
var serializer = new DataContractJsonSerializer(typeof(QualityRecordsRootObject));
var stream = new MemoryStream(Encoding.UTF8.GetBytes(response));
QualityRecordsRootObject qualityRecordsRootObject = (QualityRecordsRootObject)serializer.ReadObject(stream);
greetingOutput.Text = String.Format("{0,60}{1,60}{2,60}{3,60}",
"Brand",
"Printer",
"Printer Location",
"Date Received");
greetingOutput.Text += "\n\n";
for (int i = 0; i < qualityRecordsRootObject.auditDTOList.Count(); i++)
{
greetingOutput.Text += String.Format("{0,60}{1,60}{2,60}{3,60}",
qualityRecordsRootObject.auditDTOList[i].brandName,
qualityRecordsRootObject.auditDTOList[i].printerName,
qualityRecordsRootObject.auditDTOList[i].printerLocationName,
qualityRecordsRootObject.auditDTOList[i].receivedDate);
greetingOutput.Text += "\n";
}
}
catch (Exception ex)
{
Debug.WriteLine("exception: " + ex.Message);
greetingOutput.Text += " No Records Found!";
}
试试看
{
var response=navigationParameter.ToString();
var serializer=newdatacontractjsonserializer(typeof(QualityRecordsRootObject));
var stream=newmemoryStream(Encoding.UTF8.GetBytes(response));
QualityRecordsRootObject QualityRecordsRootObject=(QualityRecordsRootObject)序列化程序.ReadObject(流);
greetingOutput.Text=String.Format(“{0,60}{1,60}{2,60}{3,60}”,
“品牌”,
“打印机”,
“打印机位置”,
“收到日期”);
greetingOutput.Text+=“\n\n”;
for(int i=0;i
但它看起来并不好;我想有一个表格式的数据视图,看起来不错。XAML中是否有解决方法?此外,我还想为每一行添加功能,这样,如果我单击一行,它就会转到一个特定的链接 我会使用数据网格。这是DataGrid的msdn:我使用Listbox提供所需的视图,如下所示
<ListBox Name="ResultListBox"
Height="500" Width="1000" Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
Visibility="Visible" SelectionChanged="ResultListBoxSelectionChanged"
>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Width="250" Text="{Binding brandName}" />
<TextBlock Width="250" Text="{Binding printerName}" />
<TextBlock Width="250" Text="{Binding printerLocationName}" />
<TextBlock Width="250" Text="{Binding receivedDate}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
我希望这会对某人有所帮助。我已经编辑了你的标题。请看“”,其中的共识是“不,他们不应该”。我希望有这样的表格视图,但我想知道如何用XAML绑定数据。我还希望每一行都可以点击。
ResultListBox.ItemsSource = qualityRecordsRootObject.auditDTOList;