WPFで表を作りたいです。
1列目に人名
2列目に写真(複数可)
としようと考えました。
写真は土台にStackPanelを使って幅方向に複数写真(image)を並べます。
<Window x:Class="personPhoto.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="385" Width="608" Loaded="Window_Loaded"
>
<Grid>
<DataGrid Name="dataGrid"/>
</Grid>
</Window>
C#
using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace personPhoto {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
var data = new ObservableCollection<Person>(
Enumerable.Range(1, 100).Select(i => new Person {
Name = "prefix"+i.ToString("00"),
photoPanel = new StackPanel()
}));
// DataGridに設定する
this.dataGrid.ItemsSource = data;
}
}
class Person {
public string Name { get; set; }
public StackPanel photoPanel { get; set; }
}
}
実行すると2列目はStackPanelではなく、StackPanelという文字になってしまっています。
stackpanelを表示するには、どのようにしたらよいですか。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2016/02/29 00:11