Skip to content

Instantly share code, notes, and snippets.

@julesx
julesx / App.cs
Last active October 6, 2015 19:45
public class App : Application
{
public App ()
{
// The root page of your application
MainPage = new NavigationPage(new TestSwitchCell.MainPage());
}
}
using System;
using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using Xamarin.Forms;
using XLabs;
using XLabs.Forms.Controls;
namespace MyNamespace.Custom_Controls
{
public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
{
if (depObj != null)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
if (child is T)
{
public ObservableCollection<string> ComboBoxItems {get;set;}
public MainWindow()
{
ComboBoxItems = new ObservableCollection<string>();
ComboBoxItems.Add("one");
ComboBoxItems.Add("two");
DataContext = this;
}
[MarkupExtensionReturnType(typeof(ContentControl))]
public class RootObject : MarkupExtension
{
public override object ProvideValue(IServiceProvider serviceProvider)
{
var rootObjectProvider = (IRootObjectProvider)serviceProvider.GetService(typeof(IRootObjectProvider));
return rootObjectProvider?.RootObject;
}
}
<Button VerticalAlignment="Center" Style="{StaticResource HyperlinkButton}" Content="{Binding SelectedMonth.Month}">
<Button.ContextMenu>
<ContextMenu DataContext="{Binding PlacementTarget, RelativeSource={RelativeSource Self}}">
<ContextMenu.Resources>
<Style TargetType="MenuItem" BasedOn="{StaticResource MetroMenuItem}">
@julesx
julesx / Home.xaml
Last active December 3, 2015 01:15
Navigation Woes
<Page x:Class="WpfApplication1.Pages.Home"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mui="http://gu.com/ModernUI"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Title="Home">
@julesx
julesx / MainWindow.cs
Created December 3, 2015 12:24
Binding 101
public string MyBoundString { get; set; }
public MainWindow()
{
MyBoundString = "this is a bound string";
DataContext = this; // the xaml will now look to this class to resolve bindings
}
using System.Collections.ObjectModel;
using System.Windows;
namespace WpfApplication3
{
public partial class MainWindow : Window
{
public ObservableCollection<string> Columns { get; set; }
public ObservableCollection<string> Items { get; set; }
@julesx
julesx / lists
Last active January 27, 2016 15:46
<Grid Padding="5,2,5,2" VerticalOptions="CenterAndExpand">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<ListView ItemsSource="{Binding ActionTypes}" Grid.Row="0">