ContentControlWithTemplateSelector/RoomTypeConverter.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
namespace ContentControlWithTemplateSelector
{
public class RoomTypeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
var room = value as Room;
if (room == null)
{
return Visibility.Collapsed; ;
}
var roomType = parameter.ToString();
if (roomType == "Default")
{
if (room.ImageUri == null && string.IsNullOrEmpty(room.Name))
{
return Visibility.Visible;
}
}
else if (roomType == "Name")
{
if (string.IsNullOrEmpty(room.Name) == false && room.ImageUri == null)
{
return Visibility.Visible;
}
}
else
{
if (room.ImageUri != null)
{
return Visibility.Visible;
}
}
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
