Skip to content

Commit 98bf2f6

Browse files
author
Morten Nielsen
committed
Merge remote-tracking branch 'origin/main' into v.next
2 parents 896e2be + 441072c commit 98bf2f6

File tree

6 files changed

+43
-7
lines changed

6 files changed

+43
-7
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// /*******************************************************************************
2+
// * Copyright 2012-2018 Esri
3+
// *
4+
// * Licensed under the Apache License, Version 2.0 (the "License");
5+
// * you may not use this file except in compliance with the License.
6+
// * You may obtain a copy of the License at
7+
// *
8+
// * http://www.apache.org/licenses/LICENSE-2.0
9+
// *
10+
// * Unless required by applicable law or agreed to in writing, software
11+
// * distributed under the License is distributed on an "AS IS" BASIS,
12+
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// * See the License for the specific language governing permissions and
14+
// * limitations under the License.
15+
// ******************************************************************************/
16+
17+
18+
namespace Esri.ArcGISRuntime.Toolkit.Maui.Primitives
19+
{
20+
internal class BoolOrNullToBoolConverter : IValueConverter
21+
{
22+
public static readonly BoolOrNullToBoolConverter Instance = new();
23+
24+
public object? Convert(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture)
25+
{
26+
if (value is bool b)
27+
return b;
28+
return false;
29+
}
30+
31+
public object? ConvertBack(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture)
32+
{
33+
return value;
34+
}
35+
}
36+
}

src/Toolkit/Toolkit/UI/Controls/FeatureForm/AttachmentsFormElementView.Maui.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static AttachmentsFormElementView()
5353
private static object BuildDefaultTemplate()
5454
{
5555
var root = new VerticalStackLayout();
56-
root.SetBinding(VerticalStackLayout.IsVisibleProperty, static (AttachmentsFormElementView view) => view.Element?.IsVisible, source: RelativeBindingSource.TemplatedParent);
56+
root.SetBinding(VerticalStackLayout.IsVisibleProperty, static (AttachmentsFormElementView view) => view.Element?.IsVisible, source: RelativeBindingSource.TemplatedParent, converter: BoolOrNullToBoolConverter.Instance);
5757

5858
Grid header = new Grid();
5959
header.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Star));
@@ -89,7 +89,7 @@ private static object BuildDefaultTemplate()
8989

9090
Grid.SetColumn(addButton, 1);
9191
Grid.SetRowSpan(addButton, 2);
92-
addButton.SetBinding(VisualElement.IsVisibleProperty, static (AttachmentsFormElementView view) => view.Element?.IsEditable, source: RelativeBindingSource.TemplatedParent);
92+
addButton.SetBinding(VisualElement.IsVisibleProperty, static (AttachmentsFormElementView view) => view.Element?.IsEditable, source: RelativeBindingSource.TemplatedParent, converter: BoolOrNullToBoolConverter.Instance);
9393
header.Children.Add(addButton);
9494

9595
root.Children.Add(header);

src/Toolkit/Toolkit/UI/Controls/FeatureForm/ComboboxFormInputView.Maui.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static ComboBoxFormInputView()
2121
private static object BuildDefaultTemplate()
2222
{
2323
Picker view = new Picker();
24-
view.SetBinding(Picker.IsEnabledProperty, static (ComboBoxFormInputView view) => view.Element?.IsEditable, source: RelativeBindingSource.TemplatedParent);
24+
view.SetBinding(Picker.IsEnabledProperty, static (ComboBoxFormInputView view) => view.Element?.IsEditable, source: RelativeBindingSource.TemplatedParent, converter: BoolOrNullToBoolConverter.Instance);
2525
view.ItemDisplayBinding = new Binding(nameof(CodedValue.Name));
2626
view.Focused += static (s, e) => FeatureFormView.GetParent<FieldFormElementView>(s as Element)?.OnGotFocus();
2727
INameScope nameScope = new NameScope();

src/Toolkit/Toolkit/UI/Controls/FeatureForm/DateTimePickerFormInputView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private void UpdateValue()
100100
// - the date has changed, or
101101
// - the value has changed to/from null, or
102102
// - the time has changed and IncludeTime is true
103-
if (date != oldDate && (date == null || oldDate == null || date != oldDate.Value.Date || input.IncludeTime))
103+
if (date != oldDate && (date == null || oldDate == null || date.Value.Date != oldDate.Value.Date || input.IncludeTime))
104104
{
105105
#if MAUI
106106
if (date != null && oldDate != null && oldDate.Value.AddSeconds(-oldDate.Value.Second).AddMilliseconds(-oldDate.Value.Millisecond) == date.Value)

src/Toolkit/Toolkit/UI/Controls/FeatureForm/FieldFormElementView.Maui.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private static object BuildDefaultBarcodeScannerFormInputTemplate()
9898
private static object BuildDefaultTemplate()
9999
{
100100
var root = new VerticalStackLayout();
101-
root.SetBinding(VerticalStackLayout.IsVisibleProperty, static (FieldFormElementView view) => view.Element?.IsVisible);
101+
root.SetBinding(VerticalStackLayout.IsVisibleProperty, static (FieldFormElementView view) => view.Element?.IsVisible, converter: BoolOrNullToBoolConverter.Instance);
102102
var label = new Label();
103103
label.SetBinding(Label.TextProperty, static (FieldFormElementView view) => view.Element?.Label, source: RelativeBindingSource.TemplatedParent);
104104
label.SetBinding(View.IsVisibleProperty, static (Label lbl) => lbl.Text, source: RelativeBindingSource.Self, converter: EmptyStringToBoolConverter.Instance);

src/Toolkit/Toolkit/UI/Controls/FeatureForm/TextFormInputView.Maui.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ private static object BuildDefaultTemplate()
5555
Entry textInput = new Entry();
5656
Grid.SetColumnSpan(textInput, 2);
5757
root.Add(textInput);
58-
textInput.SetBinding(Entry.IsEnabledProperty, static (TextFormInputView view) => view.Element?.IsEditable, source: RelativeBindingSource.TemplatedParent);
58+
textInput.SetBinding(Entry.IsEnabledProperty, static (TextFormInputView view) => view.Element?.IsEditable, source: RelativeBindingSource.TemplatedParent, converter: BoolOrNullToBoolConverter.Instance);
5959
Editor textArea = new Editor() { IsVisible = false, HeightRequest = 100, AutoSize = EditorAutoSizeOption.Disabled };
6060
Grid.SetColumnSpan(textArea, 2);
61-
textArea.SetBinding(Editor.IsEnabledProperty, static (TextFormInputView view) => view.Element?.IsEditable, source: RelativeBindingSource.TemplatedParent);
61+
textArea.SetBinding(Editor.IsEnabledProperty, static (TextFormInputView view) => view.Element?.IsEditable, source: RelativeBindingSource.TemplatedParent, converter: BoolOrNullToBoolConverter.Instance);
6262
root.Add(textArea);
6363
Label readonlyText = new Label() { IsVisible = false, LineBreakMode = LineBreakMode.WordWrap };
6464
readonlyText.SetBinding(Label.TextProperty, static (TextFormInputView view) => view.Element?.Value, source: RelativeBindingSource.TemplatedParent);

0 commit comments

Comments
 (0)