Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 30c0b52

Browse files
committed
Updates to make it work with 4.7.
1 parent 11dfdb9 commit 30c0b52

File tree

7 files changed

+19
-38
lines changed

7 files changed

+19
-38
lines changed

DataBindingDemos/DataBindingDemos/DataBindingDemos/Converters/AllTrueMultiConverter.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
1111
{
1212
if (values == null || !targetType.IsAssignableFrom(typeof(bool)))
1313
{
14-
// Return UnsetValue to use the binding FallbackValue
15-
return BindableProperty.UnsetValue;
14+
return false;
15+
// Alternatively, return BindableProperty.UnsetValue to use the binding FallbackValue
1616
}
1717

1818
foreach (var value in values)
1919
{
2020
if (!(value is bool b))
2121
{
22-
return BindableProperty.UnsetValue;
22+
return false;
23+
// Alternatively, return BindableProperty.UnsetValue to use the binding FallbackValue
2324
}
2425
else if (!b)
2526
{

DataBindingDemos/DataBindingDemos/DataBindingDemos/Converters/AnyTrueMultiConverter.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
1111
{
1212
if (values == null || !targetType.IsAssignableFrom(typeof(bool)))
1313
{
14-
// Return UnsetValue to use the binding FallbackValue
15-
return BindableProperty.UnsetValue;
14+
return false;
15+
// Alternatively, return BindableProperty.UnsetValue to use the binding FallbackValue
1616
}
1717

1818
foreach (var value in values)
1919
{
2020
if (!(value is bool b))
2121
{
22-
return BindableProperty.UnsetValue;
22+
return false;
23+
// Alternatively, return BindableProperty.UnsetValue to use the binding FallbackValue
2324
}
2425
else if (b)
2526
{

DataBindingDemos/DataBindingDemos/DataBindingDemos/Views/MainPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
<TextCell Text="Binding Fallbacks"
144144
Detail="Provide values for multi bindings that fail"
145145
Command="{Binding NavigateCommand}"
146-
CommandParameter="{x:Type local:MultiBindingNullAndFallbackValuePage}" />
146+
CommandParameter="{x:Type local:MultiBindingFallbackValuePage}" />
147147

148148
<TextCell Text="RelativeSource Bindings"
149149
Detail="Use relative multi bindings to a templated parent"

DataBindingDemos/DataBindingDemos/DataBindingDemos/Views/MultiBindingConverterPage.xaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
Grid.Column="1"
3939
HorizontalOptions="End">
4040
<CheckBox.IsChecked>
41-
<MultiBinding Converter="{StaticResource AllTrueConverter}"
42-
FallbackValue="false">
41+
<MultiBinding Converter="{StaticResource AllTrueConverter}">
4342
<Binding Path="Employee1.IsOver16" />
4443
<Binding Path="Employee1.HasPassedTest" />
4544
<Binding Path="Employee1.IsSuspended"
@@ -54,8 +53,7 @@
5453
Grid.Column="1"
5554
HorizontalOptions="End">
5655
<CheckBox.IsChecked>
57-
<MultiBinding Converter="{StaticResource AllTrueConverter}"
58-
FallbackValue="false">
56+
<MultiBinding Converter="{StaticResource AllTrueConverter}">
5957
<Binding Path="Employee2.IsOver16" />
6058
<Binding Path="Employee2.HasPassedTest" />
6159
<Binding Path="Employee2.IsSuspended"
@@ -70,8 +68,7 @@
7068
Grid.Column="1"
7169
HorizontalOptions="End">
7270
<CheckBox.IsChecked>
73-
<MultiBinding Converter="{StaticResource AllTrueConverter}"
74-
FallbackValue="false">
71+
<MultiBinding Converter="{StaticResource AllTrueConverter}">
7572
<Binding Path="Employee3.IsOver16" />
7673
<Binding Path="Employee3.HasPassedTest" />
7774
<Binding Path="Employee3.IsSuspended"
@@ -86,8 +83,7 @@
8683
Grid.Column="1"
8784
HorizontalOptions="End">
8885
<CheckBox.IsChecked>
89-
<MultiBinding Converter="{StaticResource AllTrueConverter}"
90-
FallbackValue="false">
86+
<MultiBinding Converter="{StaticResource AllTrueConverter}">
9187
<Binding Path="Employee4.IsOver16" />
9288
<Binding Path="Employee4.HasPassedTest" />
9389
<Binding Path="Employee4.IsSuspended"
@@ -102,8 +98,7 @@
10298
Grid.Column="1"
10399
HorizontalOptions="End">
104100
<CheckBox.IsChecked>
105-
<MultiBinding Converter="{StaticResource AllTrueConverter}"
106-
FallbackValue="false">
101+
<MultiBinding Converter="{StaticResource AllTrueConverter}">
107102
<Binding Path="Employee5.IsOver16" />
108103
<Binding Path="Employee5.HasPassedTest" />
109104
<Binding Path="Employee5.IsSuspended"

DataBindingDemos/DataBindingDemos/DataBindingDemos/Views/MultiBindingNullAndFallbackValuePage.xaml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
xmlns:local="clr-namespace:DataBindingDemos"
5-
x:Class="DataBindingDemos.MultiBindingNullAndFallbackValuePage"
6-
Title="MultiBindings FallbackValue and TargetNullValue demo">
5+
x:Class="DataBindingDemos.MultiBindingFallbackValuePage"
6+
Title="MultiBindings FallbackValue demo">
77
<ContentPage.Resources>
88
<local:StringConcatenationConverter x:Key="StringConcatConverter" />
99
</ContentPage.Resources>
@@ -18,7 +18,6 @@
1818
<Label>
1919
<Label.Text>
2020
<MultiBinding FallbackValue="Name unavailable"
21-
TargetNullValue="Data undefined"
2221
Converter="{StaticResource StringConcatConverter}">
2322
<Binding Path="Employee1.Forename" />
2423
<Binding Path="Employee1.MiddleName" />
@@ -31,7 +30,6 @@
3130
<!-- This MultiBinding should return its FallbackValue,
3231
because the converter returns BindableProperty.UnsetValue -->
3332
<MultiBinding FallbackValue="Name unavailable"
34-
TargetNullValue="Data undefined"
3533
Converter="{StaticResource StringConcatConverter}">
3634
<Binding Path="Employee.Forename" />
3735
<Binding Path="Employee.MiddleName" />
@@ -42,7 +40,6 @@
4240
<Label>
4341
<Label.Text>
4442
<MultiBinding FallbackValue="Name unavailable"
45-
TargetNullValue="Data undefined"
4643
Converter="{StaticResource StringConcatConverter}">
4744
<Binding Path="Employee3.Forename" />
4845
<Binding Path="Employee3.MiddleName" />
@@ -53,7 +50,6 @@
5350
<Label>
5451
<Label.Text>
5552
<MultiBinding FallbackValue="Name unavailable"
56-
TargetNullValue="Data undefined"
5753
Converter="{StaticResource StringConcatConverter}">
5854
<Binding Path="Employee4.Forename" />
5955
<Binding Path="Employee4.MiddleName" />
@@ -64,29 +60,18 @@
6460
<Label>
6561
<Label.Text>
6662
<MultiBinding FallbackValue="Name unavailable"
67-
TargetNullValue="Data undefined"
6863
Converter="{StaticResource StringConcatConverter}">
6964
<Binding Path="Employee5.Forename" />
7065
<Binding Path="Employee5.MiddleName" />
7166
<Binding Path="Employee5.Surname" />
7267
</MultiBinding>
7368
</Label.Text>
7469
</Label>
75-
<Label>
76-
<Label.Text>
77-
<!-- This MultiBinding should return its TargetNullValue,
78-
because the converter returns null -->
79-
<MultiBinding FallbackValue="Name unavailable"
80-
TargetNullValue="Data undefined"
81-
Converter="{StaticResource StringConcatConverter}" />
82-
</Label.Text>
83-
</Label>
8470
<Label>
8571
<Label.Text>
8672
<!-- This MultiBinding should return its FallbackValue,
8773
because the converter returns BindableProperty.UnsetValue -->
8874
<MultiBinding FallbackValue="Name unavailable"
89-
TargetNullValue="Data undefined"
9075
Converter="{StaticResource StringConcatConverter}">
9176
<Binding Path="Employee6.Forename" />
9277
<Binding Path="Employee6.MiddleName" />

DataBindingDemos/DataBindingDemos/DataBindingDemos/Views/MultiBindingNullAndFallbackValuePage.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace DataBindingDemos
44
{
5-
public partial class MultiBindingNullAndFallbackValuePage : ContentPage
5+
public partial class MultiBindingFallbackValuePage : ContentPage
66
{
7-
public MultiBindingNullAndFallbackValuePage()
7+
public MultiBindingFallbackValuePage()
88
{
99
InitializeComponent();
1010
}

DataBindingDemos/DataBindingDemos/DataBindingDemos/Views/RelativeSourceMultiBindingPage.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
BackgroundColor="{Binding CardColor}"
1515
Padding="8">
1616
<Expander.IsVisible>
17-
<MultiBinding Converter="{StaticResource AllTrueConverter}"
18-
FallbackValue="false">
17+
<MultiBinding Converter="{StaticResource AllTrueConverter}">
1918
<Binding Path="IsExpanded" />
2019
<Binding Path="IsEnabled" />
2120
</MultiBinding>

0 commit comments

Comments
 (0)