Format:
Recent snippets matching tags of WPF
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.
42 Views
no comments
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();
64 Views
no comments
/// <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...
114 Views
no comments
<Popup x:Name="popup1" IsHitTestVisible="False" Placement="RelativePoint" PlacementTarget="{Binding ElementName=me}" AllowsTransparency="True"> <Border BorderBrush="{DynamicResource CellBorderBrush}" BorderThickness="2" Background="White"
102 Views
no comments
<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>
158 Views
no comments
// 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) {
276 Views
no comments
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) {
152 Views
no comments
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,
103 Views
no comments
using System; using System.Diagnostics; using System.Windows; using System.Windows.Media; public partial class MyWPFClass : Window { public MyWPFClass() { InitializeComponent(); PrintLogicalTree(0, this);
155 Views
no comments
<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
258 Views
1 comments
// 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;
284 Views
2 comments
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);
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}
211 Views
no comments
//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);
289 Views
no comments
<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>
157 Views
no comments
<Path Stroke="Black" StrokeThickness="1" Data="M 10,100 C 100,0 200,200 300,100" />
199 Views
no comments
<Image Source="sampleImages\Waterlilies.jpg" Width="200" Height="150" HorizontalAlignment="Left"> <Image.Clip> <EllipseGeometry RadiusX="100" RadiusY="75" Center="100,75"/> </Image.Clip> </Image>
151 Views
no comments
<Path Stroke="Black" StrokeThickness="2" Fill="Red" > <Path.Data> <GeometryGroup> <EllipseGeometry RadiusX="100" RadiusY="10" Center="0, 00" /> <CombinedGeometry GeometryCombineMode="Xor">
171 Views
no comments
<VisualBrush Viewport="0,0,.5,.5" ViewboxUnits="RelativeToBoundingBox" TileMode="Tile" > <VisualBrush.Visual> <ComboBox> <ListBoxItem>1</ListBoxItem> <ListBoxItem>1</ListBoxItem> <ListBoxItem>1</ListBoxItem> </ComboBox>
184 Views
no comments
<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>
165 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
