CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of WPF
C#
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interactivity;
using System.Windows.Threading;
 
namespace Behaviors
{
    /// <summary>
    /// On ListBoxes using CanContentScroll=True (virtualized), WPF layout changes will make the scrollviewer reset to zero.
by SandRock   October 26, 2011 @ 12:01am
42 Views
no comments
 
C#
public static BitmapImage _ToBitmapImage(this Bitmap bitmap)
{
    var _MemoryStream = new MemoryStream();
    bitmap.Save(_MemoryStream, ImageFormat.Png);
 
    var _BitmapImage = new BitmapImage();
    _BitmapImage.BeginInit();
    _BitmapImage.StreamSource = _MemoryStream;
    _BitmapImage.EndInit();
by Jerry Nixon   August 22, 2011 @ 9:43am
64 Views
no comments
 
C#
/// <summary>
/// State flag which indicates whether the grid is in edit
/// mode or not.
/// </summary>
public bool IsEditing { get; set; }
 
private void OnBeginEdit(object sender, DataGridBeginningEditEventArgs e)
{
  IsEditing = true;
  //in case we are in the middle of a drag/drop operation, cancel it...
by Athens Springer   June 29, 2011 @ 7:57am
114 Views
no comments
 
XML
<Popup
  x:Name="popup1"
  IsHitTestVisible="False"
  Placement="RelativePoint"
  PlacementTarget="{Binding ElementName=me}"
  AllowsTransparency="True">
  <Border
    BorderBrush="{DynamicResource CellBorderBrush}"
    BorderThickness="2"
    Background="White"
by Athens Springer   June 29, 2011 @ 7:56am
102 Views
no comments
 
XML
<Style.Triggers>
  <Trigger Property="IsEnabled" Value="false">
    <Setter Property="Background" Value="#EEEEEE" />
  </Trigger>
 
  <MultiTrigger>
    <MultiTrigger.Conditions>
      <Condition Property="HasItems" Value="false" />
      <Condition Property="Width" Value="Auto" />
    </MultiTrigger.Conditions>
by Athens Springer   June 28, 2011 @ 3:29pm
158 Views
no comments
 
C#
// DRAG
 
private void List_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    // Store the mouse position
    startPoint = e.GetPosition(null);
}
 
private void List_MouseMove(object sender, MouseEventArgs e)
{
by Athens Springer   June 28, 2011 @ 7:14am
Tags: WPF, Drag/Drop
276 Views
no comments
 
C#
public class DelegateCommand : ICommand
{
    private readonly Predicate<object> _canExecute;
    private readonly Action<object> _execute;
 
    public event EventHandler CanExecuteChanged;
 
    public DelegateCommand(Action<object> execute) 
                   : this(execute, null)
    {
by Athens Springer   June 28, 2011 @ 7:09am
Tags: C#, WPF, MVVM
152 Views
no comments
 
C#
public class Button : ButtonBase
{
// The dependency property
public static readonly DependencyProperty IsDefaultProperty;
static Button()
{
// Register the property
Button.IsDefaultProperty = DependencyProperty.Register(“IsDefault”,
typeof(bool), typeof(Button),
new FrameworkPropertyMetadata(false,
by Vijay Sharma   April 22, 2011 @ 3:12am
103 Views
no comments
 
C#
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
public partial class MyWPFClass : Window
{
public MyWPFClass()
{
InitializeComponent();
PrintLogicalTree(0, this);
by Vijay Sharma   April 22, 2011 @ 2:14am
155 Views
no comments
 
XML
<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <DockPanel LastChildFill="True">
      <Slider Name="MyZoomSlider" Minimum=".5" Maximum="20" Value="1" DockPanel.Dock="Top" />
      <TextBlock Margin="5,5,0,5" DockPanel.Dock="Top" Text="{Binding ElementName=MyZoomSlider, Path=Value, StringFormat='Current Zoom: \{0:0.0\}%'}"/>
      <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
          <Rectangle Fill="Blue" Height="100" Width="100" Margin="10" HorizontalAlignment="Left" VerticalAlignment="Top">
              <Rectangle.LayoutTransform>
                  <ScaleTransform 
by Jerry Nixon   February 14, 2011 @ 11:15am
Tags: WPF, Zoom
258 Views
1 comments
 
C#
 
// the following 3 methods are located within the code-behind for the WPF Window that serves as a host
 
public void DisplayContentPage(IContentPage p)
{
    ClearContentFrame();
 
    p.CloseRequested += new EventHandler(contentPage_CloseRequested);
    p.ContentPageError += new EventHandler<ErrorEventArgs>(contentPage_ContentPageError);
    p.Container = this;
by justin denton   February 10, 2011 @ 12:13pm
284 Views
2 comments
 
C#
public class Popper
{
    public static void PopItem(UIElement control)
    {
        DoItem(TimeSpan.FromMilliseconds(200), 1, 1.5, control);
    }
 
    public static void UnPopItem(UIElement control)
    {
        DoItem(TimeSpan.FromMilliseconds(200), 1.5, 1, control);
by Jerry Nixon   February 01, 2011 @ 4:39pm
294 Views
no comments
 
open System
open System.Windows
open System.Windows.Controls
open System.Windows.Data
 
type Person = {Name : string; Age : int}
let people =
    [|
           {Name = "nnt" ; Age = 10}
           {Name = "abc" ; Age = 11}
by nyinyithann   January 21, 2011 @ 5:34pm
Tags: F#, WPF
211 Views
no comments
 
C#
//Calling Code for VM to pass message box delegate
Func<string, string, MessageBoxButton, MessageBoxImage, MessageBoxResult> messageBox = (msg, caption, buttons, image) => MessageBox.Show(msg, caption, buttons, image);
 
//pass above variable to VM
 
//Usage of message box delegate variable inside VM
MessageBoxResult = messageBoxinVM("Test Message", "Test Caption for Message", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
by Vijay Sharma   January 13, 2011 @ 2:13am
289 Views
no comments
 
C#
<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:sys="clr-namespace:System;assembly=mscorlib">
  <Grid>
    <Grid.DataContext>
      <x:Array Type="sys:String">
        <sys:String>Red</sys:String>
        <sys:String>Yellow</sys:String>
        <sys:String>Blue</sys:String>
by Vijay Sharma   January 07, 2011 @ 8:55am
157 Views
no comments
 
XML
<Path Stroke="Black" StrokeThickness="1"  
  Data="M 10,100 C 100,0 200,200 300,100" />
by Bismark   October 30, 2010 @ 10:34pm
Tags: wpf
199 Views
no comments
 
XML
<Image
  Source="sampleImages\Waterlilies.jpg"
  Width="200" Height="150" HorizontalAlignment="Left">
  <Image.Clip>
    <EllipseGeometry
      RadiusX="100"
      RadiusY="75"
      Center="100,75"/>
  </Image.Clip>
</Image>
by Bismark   October 30, 2010 @ 10:29pm
Tags: wpf
151 Views
no comments
 
XML
<Path Stroke="Black"
             StrokeThickness="2"
             Fill="Red"
             >
           <Path.Data>
               <GeometryGroup>
                   <EllipseGeometry RadiusX="100"
                                    RadiusY="10"
                                    Center="0, 00" />
                   <CombinedGeometry GeometryCombineMode="Xor">
by Bismark   August 20, 2010 @ 9:43pm
Tags: spu, wpf
171 Views
no comments
 
XML
<VisualBrush Viewport="0,0,.5,.5"
                        ViewboxUnits="RelativeToBoundingBox"
                        TileMode="Tile"
                        >
               <VisualBrush.Visual>
                   <ComboBox>
                       <ListBoxItem>1</ListBoxItem>
                       <ListBoxItem>1</ListBoxItem>
                       <ListBoxItem>1</ListBoxItem>
                   </ComboBox>
by Bismark   August 20, 2010 @ 9:34pm
Tags: spu, wpf
184 Views
no comments
 
XML
<DrawingBrush TileMode="FlipX"
                          ViewportUnits="RelativeToBoundingBox"
                          Viewport="0,0,1,1">
                <DrawingBrush.Drawing>
                    <VideoDrawing Rect="0,0,1,1">
                        <VideoDrawing.Player>
                            <MediaPlayer x:Name="bgPlayer" />
                        </VideoDrawing.Player>
                    </VideoDrawing>
                </DrawingBrush.Drawing>
by Bismark   August 20, 2010 @ 9:10pm
Tags: spu, wpf
165 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate