Skip to content

Commit 3486e6b

Browse files
David BritchDavid Britch
authored andcommitted
Removed behaviors that aren't required and replaced with EventToCommandBehavior.
1 parent 5100678 commit 3486e6b

8 files changed

Lines changed: 38 additions & 109 deletions

File tree

src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
<converters:InverseBoolConverter x:Key="InverseBoolConverter" />
107107
<converters:ItemsToHeightConverter x:Key="ItemsToHeightConverter" />
108108
<converters:ToUpperConverter x:Key="ToUpperConverter" />
109+
<converters:WebNavigatingEventArgsConverter x:Key="WebNavigatingEventArgsConverter" />
109110

110111
<!-- STYLES -->
111112
<Style x:Key="EntryStyle"

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Behaviors/ItemTappedCommandListViewBehavior.cs

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Behaviors/WebViewNavigationBehavior.cs

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Converters/ItemTappedConverter.cs renamed to src/Mobile/eShopOnContainers/eShopOnContainers.Core/Converters/ItemTappedEventArgsConverter.cs

File renamed without changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Globalization;
3+
using Xamarin.Forms;
4+
5+
namespace eShopOnContainers.Core.Converters
6+
{
7+
public class WebNavigatingEventArgsConverter : IValueConverter
8+
{
9+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
10+
{
11+
var eventArgs = value as WebNavigatingEventArgs;
12+
if (eventArgs == null)
13+
throw new ArgumentException("Expected WebNavigatingEventArgs as value", "value");
14+
15+
return eventArgs.Url;
16+
}
17+
18+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
19+
{
20+
throw new NotImplementedException();
21+
}
22+
}
23+
}

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/BasketView.xaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8" ?>
22
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
x:Class="eShopOnContainers.Core.Views.BasketView"
@@ -76,12 +76,17 @@
7676
<!-- ITEMS -->
7777
<ListView
7878
ItemsSource="{Binding BasketItems}"
79-
behaviors:ItemTappedCommandListViewBehavior.ItemTappedCommand="{Binding AddCommand}"
8079
HeightRequest="{Binding BasketItems.Count, Converter={StaticResource ItemsToHeightConverter}}"
8180
HasUnevenRows="True"
8281
SeparatorVisibility="None"
8382
VerticalOptions="FillAndExpand"
8483
CachingStrategy="RecycleElement">
84+
<ListView.Behaviors>
85+
<behaviors:EventToCommandBehavior
86+
EventName="ItemTapped"
87+
EventArgsConverter="{StaticResource ItemTappedEventArgsConverter}"
88+
Command="{Binding AddCommand}" />
89+
</ListView.Behaviors>
8590
<ListView.ItemTemplate>
8691
<DataTemplate>
8792
<ViewCell>

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/LoginView.xaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8" ?>
22
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
x:Class="eShopOnContainers.Core.Views.LoginView"
@@ -313,8 +313,10 @@
313313
AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
314314
AbsoluteLayout.LayoutFlags="All">
315315
<WebView.Behaviors>
316-
<behaviors:WebViewNavigationBehavior
317-
NavigateCommand="{Binding NavigateCommand}"/>
316+
<behaviors:EventToCommandBehavior
317+
EventName="Navigating"
318+
EventArgsConverter="{StaticResource WebNavigatingEventArgsConverter}"
319+
Command="{Binding NavigateCommand}" />
318320
</WebView.Behaviors>
319321
</WebView>
320322
</AbsoluteLayout>

src/Mobile/eShopOnContainers/eShopOnContainers.Core/eShopOnContainers.Core.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
</Compile>
4545
<Compile Include="Behaviors\Base\BindableBehavior.cs" />
4646
<Compile Include="Behaviors\EventToCommandBehavior.cs" />
47-
<Compile Include="Behaviors\ItemTappedCommandListViewBehavior.cs" />
48-
<Compile Include="Behaviors\WebViewNavigationBehavior.cs" />
4947
<Compile Include="Controls\AddBasketButton.xaml.cs">
5048
<DependentUpon>AddBasketButton.xaml</DependentUpon>
5149
</Compile>
@@ -58,7 +56,7 @@
5856
<Compile Include="Converters\InverseBoolConverter.cs" />
5957
<Compile Include="Converters\InverseCountToBoolConverter.cs" />
6058
<Compile Include="Converters\ItemsToHeightConverter.cs" />
61-
<Compile Include="Converters\ItemTappedConverter.cs" />
59+
<Compile Include="Converters\ItemTappedEventArgsConverter.cs" />
6260
<Compile Include="Converters\ToUpperConverter.cs" />
6361
<Compile Include="Effects\LineColorEffect.cs" />
6462
<Compile Include="Exceptions\ServiceAuthenticationException.cs" />
@@ -166,6 +164,7 @@
166164
<Compile Include="Views\Templates\ProductTemplate.xaml.cs">
167165
<DependentUpon>ProductTemplate.xaml</DependentUpon>
168166
</Compile>
167+
<Compile Include="Converters\WebNavigatingEventArgsConverter.cs" />
169168
</ItemGroup>
170169
<ItemGroup>
171170
<None Include="app.config" />

0 commit comments

Comments
 (0)