的DataTemplate這可能是一個愚蠢的問題,但有可能定義爲了看我的DesignView DataTemplate中一些樣本數據的DataContext?設計時間數據在XAML
目前,我總是跑我的應用程序,看看我的變化是否有效。
E.g.用下面的代碼DesignView只是顯示一個空的列表框:
<ListBox x:Name="standardLayoutListBox" ItemsSource="{Binding myListboxItems}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Label Grid.Column="0" Content="{Binding text1}" />
<Label Grid.Column="1" Content="{Binding text2}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
請參閱這篇文章提出的解決方案:http://stackoverflow.com/questions/1889966/what-approaches-are-available-to-dummy-設計時數據在WPF –
現在我讀了很多樣本,但我真的不能在設計時填充這個簡單的Listbox。我確定我錯過了一些東西,但是我找不到什麼。你有可能爲我的列表框提供一個工作示例嗎? – MTR
請參閱下面的示例代碼的答案。 –