Skip to content

Instantly share code, notes, and snippets.

@odugen
odugen / FolderDialogBehavior.cs
Created January 13, 2015 08:01
WPF MVVM Folder dialog
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Interactivity;
using Button = System.Windows.Controls.Button;
namespace FolderDialog
{
public class FolderDialogBehavior : Behavior<Button>
@odugen
odugen / window.xaml
Created December 16, 2014 14:57
ContentPresenter INotifyDataErrorInfo red border fix
<Window x:Class="TestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="TestWindow" Height="300" Width="300">
<Window.Resources>
<DataTemplate DataType="{x:Type TestViewModel}">
<Grid>
<TestView />
</Grid>
</DataTemplate>
@odugen
odugen / DisableSignManifest.msbuild
Created December 12, 2014 06:19
MSBuild update C# project with XMLPoke
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets="DisableMySignedProjectSignManifest">
<Target Name="DisableMySignedProjectSignManifest">
<XmlPoke XmlInputPath="MySignedProject.csproj"
Namespaces="&lt;Namespace Prefix='x' Uri='http://schemas.microsoft.com/developer/msbuild/2003'/&gt;"
Query="x:Project/x:PropertyGroup/x:SignManifests" Value="false" />
</Target>
</Project>
@odugen
odugen / style.xaml
Created June 11, 2014 07:26
WPF HorizontalHeaderedContentControl style
<Window.Resources>
<Style TargetType="{x:Type HeaderedContentControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type HeaderedContentControl}">
<Grid Margin="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="172"/>
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" />
@odugen
odugen / Main.cs
Created May 3, 2014 12:10
C# runs R code from CMD using string.
using System.IO;
using System;
class Program
{
static void Main()
{
var batch = @"
print(""start"");
args <- commandArgs(trailingOnly = TRUE)
@odugen
odugen / usercountrol.xaml
Created April 14, 2014 06:54
ComboBox ItemsSource to parent collection binding
<!-- In user countrol resources -->
<UserControl.Resources>
<CollectionViewSource Source="{Binding Currencies}" x:Key="Currencies"/>
</UserControl.Resources>
<!-- below inside ex. DataGrid -->
<ComboBox ItemsSource="{Binding Source={StaticResource Currencies}}" IsSynchronizedWithCurrentItem="False"
DisplayMemberPath="IsoCode"
SelectedItem="{Binding BaseCurrency}"/>
@odugen
odugen / FolderDialogBehavior.cs
Created March 31, 2014 11:35
WPF FolderDialog Behavior
public class FolderDialogBehavior : Behavior<Button>
{
public string SetterName { get; set; }
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.Click += OnClick;
}
@odugen
odugen / FilterConfig.cs
Created December 10, 2012 11:01
Elmah.MVC Web API configuration
namespace Mvc
{
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
GlobalConfiguration.Configuration.Filters.Add(new ElmahHandledErrorLoggerFilter());
filters.Add(new HandleErrorAttribute());
}
}