我正試圖從here擴展RSS閱讀器示例。如何獲得綁定控件在綁定空虛時報告「空」?
我已將應用程序轉換爲全景圖。我已經制作了第一個全景項目加載了我的提要,第二個項目有相應複選框的類別。這些類別是綁定到Categories類的,可以從XML文件填充。
不管怎麼說,「我的供稿」部分,其中有代碼看起來像這樣:
<TextBlock x:Name="ItemName" Text="{Binding ItemTitle}" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="ItemDetails" Text="{Binding ItemDetails}" Style="{StaticResource PhoneTextSubtleStyle}"/>
和我想要得到它,以顯示「空」時,有列表中沒有飼料(飼料在相鄰面板中的複選框被選中時被填充)。因此,我將此代碼添加到MainPage.xaml.cs中的OnNavigatedTo方法
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
this.DataContext = App.Model;
base.OnNavigatedTo(e);
// If there are no feeds yet, let the user know
if (App.Model.FeedItems.Count == 0)
{
App.Model.FeedItems.Add(
new ViewModel.ItemModel()
{
ItemDetails = "",
ItemTitle = "Empty!",
ItemLink = "#"
}
);
}
}
但這不是正確的方法。現在,如果我導航到其他頁面並返回,並且列表中有條目,我仍然會看到「空」,然後是條目。我該如何解決?
另外,當「Empty!」實際上,我仍然可以點擊鏈接(上面的ItemLink);如何禁用這種情況下的點擊事件?