Skip to content

Instantly share code, notes, and snippets.

View aybarsyalcin's full-sized avatar

Aybars Yalcin aybarsyalcin

View GitHub Profile
import Foundation
class Circle : Shape{
func draw() {
print("Inside \(self.dynamicType)::draw() method.")
}
}
@aybarsyalcin
aybarsyalcin / Get All Cell on Listview
Last active March 17, 2022 22:53
Xamarin.Forms Get All Cell on Listview
IEnumerable<PropertyInfo> pInfos = (xListView as ItemsView<Cell>).GetType().GetRuntimeProperties();
var templatedItems = pInfos.FirstOrDefault(info => info.Name == "TemplatedItems");
if (templatedItems != null)
{
var cells = templatedItems.GetValue(xListView);
Xamarin.Forms.ITemplatedItemsList<Xamarin.Forms.Cell> listCell = cells as Xamarin.Forms.ITemplatedItemsList<Xamarin.Forms.Cell>;
ViewCell currentCell = listCell[position] as ViewCell;
currentCell.View.BackgroundColor = Color.White;
foreach (ViewCell cell in cells as Xamarin.Forms.ITemplatedItemsList<Xamarin.Forms.Cell>)
@aybarsyalcin
aybarsyalcin / BaseViewModel.cs
Last active December 12, 2017 08:58
ViewModel Support - Snippet
namespace namespaces
{
public class BaseViewModel : ObservableObject
{
}
}
@aybarsyalcin
aybarsyalcin / Page.cs
Last active December 12, 2017 13:10
Title Detail ViewCell on ListView
<StackLayout>
<ListView x:Name="xCatalogList" ItemsSource="{Binding Items}" VerticalOptions="FillAndExpand" HasUnevenRows="true" ItemSelected="Handle_ItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10">
<Label Text="{Binding Text}" LineBreakMode="NoWrap" Style="{DynamicResource ListItemTextStyle}" FontSize="16" />
<Label Text="{Binding Description}" LineBreakMode="NoWrap" Style="{DynamicResource ListItemDetailTextStyle}" FontSize="13" />
</StackLayout>
</ViewCell>
@aybarsyalcin
aybarsyalcin / RuntimePlatform.cs
Created December 12, 2017 13:14
Device.RuntimePlatform using with switch
switch (Device.RuntimePlatform)
{
case Device.iOS:
itemsPage = new NavigationPage(new ItemsPage())
{
Title = "Items"
};
aboutPage = new NavigationPage(new AboutPage())
{
@aybarsyalcin
aybarsyalcin / HomePage.cs
Last active December 12, 2017 21:13
Listview with SwitchCell & Itemsource of Listview is set to "ItemsSource="{x:Static local:HomeViewModel.lights}"
?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="twoWayBinding.SwitchPage"
Title="Switch Panel"
xmlns:local="clr-namespace:twoWayBinding;assembly=twoWayBinding">
<ContentPage.Content>
<ListView x:Name="listView" SeparatorVisibility="None" ItemsSource="{x:Static local:HomeViewModel.lights}">
<ListView.ItemTemplate>
<DataTemplate>
@aybarsyalcin
aybarsyalcin / BaseClient.cs
Created December 13, 2017 08:14
When start a new project, I need to BaseClient snippet
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace yournamespaces
@aybarsyalcin
aybarsyalcin / AndroidManifest.xml
Created December 13, 2017 08:52
AndroidManifest for android
<uses-sdk android:minSdkVersion="19" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="YourLabel" android:largeHeap="true">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="YOUR_API_KEY" />
@aybarsyalcin
aybarsyalcin / ImageTitle.cs
Created December 13, 2017 13:08
ImageTitle on ViewCell
<ListView x:Name="xListview" ItemsSource="{Binding Items}" SeparatorVisibility="None" VerticalOptions="FillAndExpand" HasUnevenRows="true" ItemSelected="Handle_ItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid BackgroundColor="Red" HeightRequest="100" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackLayout Grid.Column="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
@aybarsyalcin
aybarsyalcin / Listview.cs
Created December 14, 2017 07:47
Listview selection disable
//On constructor
xCatalogList.ItemSelected += (senders, e) => {
if (e.SelectedItem == null) return;
((ListView)senders).SelectedItem = null;
};
async void Handle_ItemSelected(object sender, Xamarin.Forms.SelectedItemChangedEventArgs e)
{
if (e.SelectedItem == null) return;