Skip to content

Instantly share code, notes, and snippets.

// Listing 11-1. Creating a RandomTicker that defines, publishes, and triggers an event
open System
open System.Timers
type RandomTicker(approxInterval) =
let timer = new Timer()
let rnd = new System.Random(99)
let tickEvent = new Event<float> ()
let chooseInterval() : float =
approxInterval + approxInterval / 4.0 - float(rnd.Next((int)(approxInterval / 2.0)))
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication2
{
class SomeStringObject
{
public string S { get; private set; }
public SomeStringObject(string s) { this.S = s; }
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding XXX}" Value="YYY"/>
<!-- Doesn't work -->
<Condition Binding="{Binding DataContext.ZZZ, RelativeSource={RelativeSource FindAncestor, AncestorType=ListBox}}" Value="KKK"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Conditions>
<!-- works -->
<Condition Binding="{Binding DataContext.ZZZ, RelativeSource={RelativeSource FindAncestor, AncestorType=ListBox}}" Value="KKK"/>
</MultiDataTrigger.Conditions>
@franssu
franssu / MainWindow.xaml
Last active October 3, 2016 16:43
VMTrees
<Window x:Class="VMTreeBuilder.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TreeView x:Name="tv" ItemsSource="{Binding}">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Value}"/>
</HierarchicalDataTemplate>
foo ()
{
dirs=`find . -type d -name "*$1*"`
files=`find . -type f -name "*$1*"`
echo "Dirs:"
echo ${dirs}
echo "Files:"
echo ${files}
@franssu
franssu / RepetitionAdorner.cs
Last active August 29, 2015 14:24
Displaying a cascade of control copies, using the adorner layer and a behavior
using System.Linq;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;
namespace WpfApplication1
{
public class RepetitionAdorner : Adorner
{
private int count;