0
這是用於UWP的C++/CX和XAML。假設我有一個班級:在GridView中實現按鈕的最佳方式是什麼?
public ref class foo
{
private:
String^ title;
String^ printstring;
public:
foo()
{
title = "this is my title";
printstring = "test";
}
property String^ Title
{
String^ get()
{
return title;
}
}
}
我有一個向量Platform::Collections::Vector<foo^>^ testbind
。我也有一個屬性返回該向量。在我的XAML中,我有一個GridView,用的ItemSource設置爲屬性testbind
和ItemTemplate中設置這樣的:
<DataTemplate x:DataType="local:foo">
<StackPanel Height="100" Width="100">
<TextBlock Text="{x:Bind Title} TextWrapping="WrapWholeWords"/>
<Button x:Name=button/>
</StackPanel>
</DataTemplate>
我如何使它所以當我按一下按鈕,我可以做一些與printstring
在代碼後面?在這種假設情況下,所有標題和印記串都是相同的,但在我的實際項目中,它們對於矢量的每個成員都是不同的。