Это распространенный формат XAML и обязательный вопрос.Чтобы выполнить ваши требования, вам нужно поместить слой в ваш DataTemplate, затем вы можете скрыть / показать его в соответствии с его доступностью / недоступностью.
Я сделал простой пример кода для вашей справки:
<ListView ItemsSource="{x:Bind tests}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="local:Test">
<Grid>
<Border Background="Gray" Visibility="{x:Bind IsAvailable}" Opacity="0.8">
<TextBlock Text="NOT AVAILABLE" Foreground="White" FontWeight="Bold" FontSize="50"></TextBlock>
</Border>
<StackPanel Orientation="Horizontal" >
<TextBlock Text="{x:Bind Name}"></TextBlock>
<TextBlock Text="{x:Bind Score}" Margin="20 0 0 0"></TextBlock>
<TextBlock Text="{x:Bind Cote}" Margin="20 0 0 0"></TextBlock>
</StackPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
public sealed partial class MainPage : Page
{
public ObservableCollection<Test> tests;
public MainPage()
{
this.InitializeComponent();
tests = new ObservableCollection<Test>();
tests.Add(new Test() {Name="Star",Score=10,Cote=2.8,IsAvailable=Visibility.Collapsed });
tests.Add(new Test() { Name = "Cera", Score = 0, Cote = 6.6, IsAvailable = Visibility.Visible });
}
}
public class Test:INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void RaisePropertyChanged(string PropertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this,new PropertyChangedEventArgs(PropertyName));
}
}
private string name;
public string Name
{
get { return name; }
set
{
name = value;
RaisePropertyChanged("Name");
}
}
private int score;
public int Score
{
get { return score; }
set
{
score = value;
RaisePropertyChanged("Score");
}
}
private double cote;
public double Cote
{
get { return cote; }
set
{
cote = value;
RaisePropertyChanged("Cote");
}
}
private Visibility isAvailable;
public Visibility IsAvailable
{
get { return isAvailable; }
set
{
isAvailable = value;
RaisePropertyChanged("IsAvailable");
}
}
}