-
Notifications
You must be signed in to change notification settings - Fork 748
Expand file tree
/
Copy pathLastItemToVisibilityConverter.cs
More file actions
38 lines (33 loc) · 1.24 KB
/
LastItemToVisibilityConverter.cs
File metadata and controls
38 lines (33 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Diagnostics;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace NuGet.PackageManagement.UI
{
internal class LastItemToVisibilityConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values != null && values.Length == 2
&& values[0] is int currentIndex
&& values[1] is int length)
{
if (currentIndex < 0 || length < 1 || currentIndex >= length)
{
return DependencyProperty.UnsetValue;
}
int lastIndex = length - 1;
return Equals(currentIndex, lastIndex) ? Visibility.Collapsed : Visibility.Visible;
}
return DependencyProperty.UnsetValue;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
Debug.Fail("Not Implemented");
return null;
}
}
}