Skip to content

Instantly share code, notes, and snippets.

View ServerInfoVM.cs
using System;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
namespace d2mSoftware
{
[Serializable]
public class ServerInfoVm : INotifyPropertyChanged, IDataErrorInfo
View gist:6596268
<ContextMenu Name="MainDropDownMenu" ItemsSource={Binding ServerList}>
<ContextMenu.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ServerName}" />
</DataTemplate>
</ContextMenu.ItemTemplate>
<MenuItem Header="Settings" Click="OpenSettings">
<MenuItem.Icon>
<TextBlock Text="Hardcoded Value" />
View gist:6687138
<Window x:Class="WpfApplication4.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>
<Grid.Resources>
<Style x:Key="HiddenTabItem" TargetType="{x:Type TabItem}">
<!--<Setter Property="Visibility" Value="Visible"/>-->
View gist:6689992
<Window x:Class="WpfApplication5.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">
<Window.Resources>
<Storyboard x:Key="animate">
<ObjectAnimationUsingKeyFrames BeginTime="0:0:0" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0">
View MainWindow.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
View panel.xaml
<StackPanel Visibility="Hidden">
<StackPanel.Style>
<Style>
<Style.Triggers>
<MultiDataTrigger>
View emptylistbox.xaml
<Window x:Class="WpfApplication16.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">
<Window.Resources>
<Style TargetType="ListBox" x:Key="ListStyle" BasedOn="{StaticResource {x:Type ListBox}}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Items.Count}" Value="0">
<Setter Property="Template">
View resizeimage.cs
public static Image ResizeImage(Image initImage, int templateWidth, int templateHeight)
{
Image templateImage = null;
try
{
if (initImage.Width <= templateWidth && initImage.Height <= templateHeight)
templateImage = initImage;
else
{
View fancyscrollbar.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type ScrollViewer}" x:Key="ScrollViewerControlTemplate">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollViewer}">
<Grid x:Name="Grid" Background="{TemplateBinding Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
View main.cs
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace WpfApplication12
{
public partial class MainWindow : INotifyPropertyChanged
{
You can’t perform that action at this time.