From 4c57983da40b64fe566c2b003a5cf95c49371a83 Mon Sep 17 00:00:00 2001 From: JH Choi Date: Wed, 27 Sep 2017 14:10:25 +0900 Subject: Changed to disable option button if there are no installed applications Signed-off-by: JH Choi i Change-Id: Ia9480f341253cd54094790a0a146d3464a25a376 --- TVApps/TVApps/Controls/EnableStateConverter.cs | 22 ++++++++++++++++++++++ TVApps/TVApps/Views/FooterNormalStatus.xaml.cs | 4 ++++ 2 files changed, 26 insertions(+) create mode 100644 TVApps/TVApps/Controls/EnableStateConverter.cs diff --git a/TVApps/TVApps/Controls/EnableStateConverter.cs b/TVApps/TVApps/Controls/EnableStateConverter.cs new file mode 100644 index 0000000..2908c48 --- /dev/null +++ b/TVApps/TVApps/Controls/EnableStateConverter.cs @@ -0,0 +1,22 @@ +using LibTVRefCommonPortable.DataModels; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using Xamarin.Forms; + +namespace TVApps.Controls +{ + class EnableStateConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return ((List)value).Count > 0; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/TVApps/TVApps/Views/FooterNormalStatus.xaml.cs b/TVApps/TVApps/Views/FooterNormalStatus.xaml.cs index 07bc4fd..bc133d1 100755 --- a/TVApps/TVApps/Views/FooterNormalStatus.xaml.cs +++ b/TVApps/TVApps/Views/FooterNormalStatus.xaml.cs @@ -20,6 +20,7 @@ using LibTVRefCommonPortable.Utils; using System.Windows.Input; using System; using System.Collections.Generic; +using TVApps.Controls; namespace TVApps.Views { @@ -124,6 +125,9 @@ namespace TVApps.Views FontSize = SizeUtils.GetFontSize(28), }; OptionButton.Clicked += OnOptionsClicked; + Binding binding = new Binding("InstalledAppList"); + binding.Converter = new EnableStateConverter(); + OptionButton.SetBinding(Button.IsEnabledProperty, binding); this.Children.Add(OptionButton, heightConstraint: Constraint.Constant(SizeUtils.GetHeightSize(80)), -- cgit v1.2.3