TemplateSwitcher
ShowAlternativeTemplate="{Binding Options, Converter={StaticResource ListToVisibilityConverter}}">
TemplateSwitcher.AlternativeTemplate starts
shows a watermark // Line A
TemplateSwitcher.AlternativeTemplate ends
// actual template which shows up if alternative template is not the case
ScrollViewer
ListView
// SHows a list of options and with each option , there are two buttons - Accept option/ Reject option
/* Clicking on Accept sets the isOptionAccepted to true; */
ListView ends
ScrollViewer ends
Tempalte switcherends
我想要实现的目标是:
现在,当所有选项被接受时,这意味着UI中不会显示任何选项,这是正确发生的。但是,因此我希望它在XAML的A行显示替代模板(水印)。我无法实现这一点。
看一下this示例,但我仍无法解决此问题。使用此转换器,选项根本不会显示在列表中。我在转换器中设置了一个断点,每当我点击Accept时我都希望达到断点(因为那是修改对象的属性 EachOption ) 任何帮助表示赞赏。
以下是ListToVisibilityConverter
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return true;
else
{
ObservableCollection<EachOption> optionList= value as ObservableCollection;
if (optionList != null)
{
foreach (EachOption eachOpt in optionList)
{
if (eachOpt.isOptionAccepted!= true)
return true;
else
return false;
}
}
}
return true;
}