由于您没有提供任何代码,因此无法回答您是否正确地进行此操作。
下面是我该怎么做。我的看法型号:
public class AttachmentInfo : ViewModel
{
public string Path { get/set omitted }
}
public class EmailInfo : ViewModel
{
public ICollection<AttachmentInfo> Attachments { get omitted }
public ICommand AddAttachmentCommand { get omitted }
// logic for adding attachment simply adds another item to Attachments collection
}
在我看来,这样的事情:
<ScrollViewer>
<ItemsControl ItemsSource="{Binding Attachments}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding Path}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<Button Command="{Binding AddAttachmentCommand}">Add</Button>
这似乎是一个很好的方式给我。你只需要使用ScrollViewer来环绕Grid,并且不应该有任何问题。我建议你尝试一下,看看它的表现如何。 – Vale 2011-06-10 08:56:23