Skip to content

Instantly share code, notes, and snippets.

<controls:XamlLineArt LineArt="{TemplateBinding LineArt}" HorizontalAlignment="Center"
MaxWidth="{TemplateBinding ImageMaxWidth}" MaxHeight="{TemplateBinding ImageMaxHeight}"
Margin="{TemplateBinding ImageMargin}" DockPanel.Dock="{TemplateBinding ImagePosition}">
<controls:XamlLineArt.Triggers>
<DataTrigger Value="true" Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type controls:LineArtButton}}}">
<!-- This seems to set Stroke on LineArtButton and not XamlLineArt... :( -->
<Setter Property="Stroke" Value="Blue" />
</DataTrigger>
</controls:XamlLineArt.Triggers>
</controls:XamlLineArt>
@aneves
aneves / SerializationOfStructsIsNotCalled.cs
Created December 6, 2013 19:32
Minimalist sample: ORMLite does not properly serialize structs.
using System;
using System.Globalization;
using System.Linq;
using System.Threading;
using ServiceStack;
using ServiceStack.OrmLite;
using ServiceStack.Text;
namespace ORMLiteSerializationTests
{
@aneves
aneves / StringExtensions.cs
Last active September 26, 2023 22:00
Extension method to add ellipsis at the end of a string if it is too big.
private const string EllipsisString = "…";
public static string Ellipsis(this string str, int maxChars, bool breakOnNewLine = false) {
if (maxChars < 1) {
throw new ArgumentOutOfRangeException(nameof(maxChars), "maxChars must be 1 or more.");
}
string changed = str;
if (breakOnNewLine) {
int newLine = changed.IndexOf('\n');
if (newLine > -1) {
changed = changed.Substring(0, newLine) + EllipsisString;