Table of Contents

Class XamlHelper

Namespace
Ecng.Xaml
Assembly
StockSharp.Xaml.dll
public static class XamlHelper
Inheritance
XamlHelper
Inherited Members

Fields

DialogResultProperty

public static readonly DependencyProperty DialogResultProperty

Field Value

DependencyProperty

DisabledCommand

Disabled command.

public static readonly ICommand DisabledCommand

Field Value

ICommand

Properties

CurrentThreadDispatcher

public static Dispatcher CurrentThreadDispatcher { get; }

Property Value

Dispatcher

Methods

CopyToClipboard<T>(T)

public static void CopyToClipboard<T>(this T value)

Parameters

value T

Type Parameters

T

DeleteHideable(Window)

public static void DeleteHideable(this Window window)

Parameters

window Window

EnsureUIThread()

public static void EnsureUIThread()

EnsureUIThread(object)

Checks if supplied dispatcher/dispatcher object OR current thread is associated with Dispatcher.

public static void EnsureUIThread(this object obj)

Parameters

obj object

Any DispatcherObject or Dispatcher or anything else (to check using Dispatcher.FromThread())

FindLogicalChild<T>(DependencyObject)

public static T FindLogicalChild<T>(this DependencyObject obj) where T : DependencyObject

Parameters

obj DependencyObject

Returns

T

Type Parameters

T

FindLogicalParentOfType<T>(DependencyObject)

public static T FindLogicalParentOfType<T>(this DependencyObject child) where T : DependencyObject

Parameters

child DependencyObject

Returns

T

Type Parameters

T

FindVisualChild<T>(DependencyObject)

public static T FindVisualChild<T>(this DependencyObject obj) where T : DependencyObject

Parameters

obj DependencyObject

Returns

T

Type Parameters

T

FindVisualChilds<T>(DependencyObject)

public static IEnumerable<T> FindVisualChilds<T>(this DependencyObject obj) where T : DependencyObject

Parameters

obj DependencyObject

Returns

IEnumerable<T>

Type Parameters

T

FromWpf(HorizontalAlignment)

Convert HorizontalAlignment value to Ecng.Drawing.HorizontalAlignment.

public static HorizontalAlignment FromWpf(this HorizontalAlignment value)

Parameters

value HorizontalAlignment

HorizontalAlignment value.

Returns

HorizontalAlignment

Ecng.Drawing.HorizontalAlignment value.

FromWpf(Brush)

Convert Brush value to DrawingBrush.

public static Brush FromWpf(this Brush value)

Parameters

value Brush

Brush value.

Returns

Brush

DrawingBrush value.

FromWpf(Color)

Convert Color value to Color.

public static Color FromWpf(this Color value)

Parameters

value Color

Color value.

Returns

Color

Color value.

FromWpf(Point)

Convert Point value to PointF.

public static PointF FromWpf(this Point value)

Parameters

value Point

Point value.

Returns

PointF

PointF value.

FromWpf(Thickness)

Convert Thickness value to Ecng.Drawing.Thickness.

public static Thickness FromWpf(this Thickness value)

Parameters

value Thickness

Thickness value.

Returns

Thickness

Ecng.Drawing.Thickness value.

FromWpf(VerticalAlignment)

Convert VerticalAlignment value to Ecng.Drawing.VerticalAlignment.

public static VerticalAlignment FromWpf(this VerticalAlignment value)

Parameters

value VerticalAlignment

VerticalAlignment value.

Returns

VerticalAlignment

Ecng.Drawing.VerticalAlignment value.

GetActiveOrMainWindow(Application)

public static Window GetActiveOrMainWindow(this Application app)

Parameters

app Application

Returns

Window

GetActiveWindow(Application)

public static Window GetActiveWindow(this Application app)

Parameters

app Application

Returns

Window

GetActiveWindows(Application)

public static IEnumerable<Window> GetActiveWindows(this Application app)

Parameters

app Application

Returns

IEnumerable<Window>

GetActualSize(FrameworkElement)

public static (int width, int height) GetActualSize(this FrameworkElement elem)

Parameters

elem FrameworkElement

Returns

(int width, int height)

GetBrush(DrawingImage)

public static Brush GetBrush(this DrawingImage source)

Parameters

source DrawingImage

Returns

Brush

GetDialogResult(DependencyObject)

Boilerplate code to register attached property "bool? DialogResult"

public static bool? GetDialogResult(DependencyObject obj)

Parameters

obj DependencyObject

Returns

bool?

GetImage(FrameworkElement)

public static BitmapSource GetImage(this FrameworkElement elem)

Parameters

elem FrameworkElement

Returns

BitmapSource

GetImage(Visual, int, int)

public static BitmapSource GetImage(this Visual visual, int width, int height)

Parameters

visual Visual
width int
height int

Returns

BitmapSource

GetImage(Visual, (int width, int height))

public static BitmapSource GetImage(this Visual visual, (int width, int height) size)

Parameters

visual Visual
size (int width, int height)

Returns

BitmapSource

GetWindow(DependencyObject)

public static Window GetWindow(this DependencyObject obj)

Parameters

obj DependencyObject

Returns

Window

GuiAsync(Dispatcher, Action)

public static void GuiAsync(this Dispatcher dispatcher, Action action)

Parameters

dispatcher Dispatcher
action Action

GuiAsync(Dispatcher, Action, DispatcherPriority)

public static void GuiAsync(this Dispatcher dispatcher, Action action, DispatcherPriority priority)

Parameters

dispatcher Dispatcher
action Action
priority DispatcherPriority

GuiAsync(DispatcherObject, Action)

public static void GuiAsync(this DispatcherObject obj, Action action)

Parameters

obj DispatcherObject
action Action

GuiSync(Dispatcher, Action)

public static void GuiSync(this Dispatcher dispatcher, Action action)

Parameters

dispatcher Dispatcher
action Action

GuiSync(Dispatcher, Action, DispatcherPriority)

public static void GuiSync(this Dispatcher dispatcher, Action action, DispatcherPriority priority)

Parameters

dispatcher Dispatcher
action Action
priority DispatcherPriority

GuiSync(DispatcherObject, Action)

public static void GuiSync(this DispatcherObject obj, Action action)

Parameters

obj DispatcherObject
action Action

GuiSync<T>(Dispatcher, Func<T>)

public static T GuiSync<T>(this Dispatcher dispatcher, Func<T> func)

Parameters

dispatcher Dispatcher
func Func<T>

Returns

T

Type Parameters

T

GuiSync<T>(Dispatcher, Func<T>, DispatcherPriority)

public static T GuiSync<T>(this Dispatcher dispatcher, Func<T> func, DispatcherPriority priority)

Parameters

dispatcher Dispatcher
func Func<T>
priority DispatcherPriority

Returns

T

Type Parameters

T

GuiSync<T>(DispatcherObject, Func<T>)

public static T GuiSync<T>(this DispatcherObject obj, Func<T> func)

Parameters

obj DispatcherObject
func Func<T>

Returns

T

Type Parameters

T

GuiThreadGetAsync(Action<CancellationToken>, CancellationToken)

public static Task GuiThreadGetAsync(Action<CancellationToken> action, CancellationToken token)

Parameters

action Action<CancellationToken>
token CancellationToken

Returns

Task

GuiThreadGetAsync(Func<CancellationToken, Task>, CancellationToken)

public static Task GuiThreadGetAsync(Func<CancellationToken, Task> func, CancellationToken token)

Parameters

func Func<CancellationToken, Task>
token CancellationToken

Returns

Task

GuiThreadGetAsync<TResult>(Func<CancellationToken, Task<TResult>>, CancellationToken)

public static Task<TResult> GuiThreadGetAsync<TResult>(Func<CancellationToken, Task<TResult>> func, CancellationToken token)

Parameters

func Func<CancellationToken, Task<TResult>>
token CancellationToken

Returns

Task<TResult>

Type Parameters

TResult

GuiThreadGetAsync<TResult>(Func<CancellationToken, TResult>, CancellationToken)

public static Task<TResult> GuiThreadGetAsync<TResult>(Func<CancellationToken, TResult> func, CancellationToken token)

Parameters

func Func<CancellationToken, TResult>
token CancellationToken

Returns

Task<TResult>

Type Parameters

TResult

IsDesignMode(DependencyObject)

public static bool IsDesignMode(this DependencyObject obj)

Parameters

obj DependencyObject

Returns

bool

IsUI()

Determines the current thread is associated with Dispatcher.

public static bool IsUI()

Returns

bool

Check result.

LoadViewFromUri(Control, string)

public static void LoadViewFromUri(this Control control, string baseUri)

Parameters

control Control
baseUri string

MakeHideable(Window)

public static void MakeHideable(this Window window)

Parameters

window Window

SaveImage(BitmapSource, Stream)

public static void SaveImage(this BitmapSource image, Stream file)

Parameters

image BitmapSource
file Stream

SetBindings(DependencyObject, DependencyProperty, object, string, BindingMode, IValueConverter, object)

public static void SetBindings(this DependencyObject obj, DependencyProperty property, object dataObject, string path, BindingMode mode = BindingMode.TwoWay, IValueConverter converter = null, object parameter = null)

Parameters

obj DependencyObject
property DependencyProperty
dataObject object
path string
mode BindingMode
converter IValueConverter
parameter object

SetBindings(DependencyObject, DependencyProperty, object, PropertyPath, BindingMode, IValueConverter, object)

public static void SetBindings(this DependencyObject obj, DependencyProperty property, object dataObject, PropertyPath path, BindingMode mode = BindingMode.TwoWay, IValueConverter converter = null, object parameter = null)

Parameters

obj DependencyObject
property DependencyProperty
dataObject object
path PropertyPath
mode BindingMode
converter IValueConverter
parameter object

SetDialogResult(DependencyObject, bool?)

public static void SetDialogResult(DependencyObject obj, bool? value)

Parameters

obj DependencyObject
value bool?

SetMultiBinding(DependencyObject, DependencyProperty, IMultiValueConverter, params Binding[])

public static void SetMultiBinding(this DependencyObject obj, DependencyProperty prop, IMultiValueConverter conv, params Binding[] bindings)

Parameters

obj DependencyObject
prop DependencyProperty
conv IMultiValueConverter
bindings Binding[]

ShowModal(CommonDialog, DependencyObject)

public static bool ShowModal(this CommonDialog dlg, DependencyObject obj)

Parameters

dlg CommonDialog
obj DependencyObject

Returns

bool

ShowModal(CommonDialog, Window)

public static bool ShowModal(this CommonDialog dlg, Window owner)

Parameters

dlg CommonDialog
owner Window

Returns

bool

ShowModal(Window)

public static bool ShowModal(this Window wnd)

Parameters

wnd Window

Returns

bool

ShowModal(Window, DependencyObject)

public static bool ShowModal(this Window wnd, DependencyObject obj)

Parameters

wnd Window
obj DependencyObject

Returns

bool

ShowModal(Window, Window)

public static bool ShowModal(this Window wnd, Window owner)

Parameters

wnd Window
owner Window

Returns

bool

ShowModel<TWindow>(object, DependencyObject)

public static bool ShowModel<TWindow>(this object model, DependencyObject owner) where TWindow : Window, new()

Parameters

model object
owner DependencyObject

Returns

bool

Type Parameters

TWindow

ToBitmapImage(Stream, BitmapCreateOptions, BitmapCacheOption, bool)

public static BitmapImage ToBitmapImage(this Stream streamSource, BitmapCreateOptions options = BitmapCreateOptions.None, BitmapCacheOption cache = BitmapCacheOption.Default, bool freeze = true)

Parameters

streamSource Stream
options BitmapCreateOptions
cache BitmapCacheOption
freeze bool

Returns

BitmapImage

ToColor(int)

public static Color ToColor(this int color)

Parameters

color int

Returns

Color

ToInt(Color)

public static int ToInt(this Color color)

Parameters

color Color

Returns

int

ToTransparent(Color, byte)

public static Color ToTransparent(this Color color, byte alpha)

Parameters

color Color
alpha byte

Returns

Color

ToWpf(Brush)

Convert DrawingBrush value to Brush.

public static Brush ToWpf(this Brush value)

Parameters

value Brush

DrawingBrush value.

Returns

Brush

Brush value.

ToWpf(HorizontalAlignment)

Convert Ecng.Drawing.HorizontalAlignment value to HorizontalAlignment.

public static HorizontalAlignment ToWpf(this HorizontalAlignment value)

Parameters

value HorizontalAlignment

Ecng.Drawing.HorizontalAlignment value.

Returns

HorizontalAlignment

HorizontalAlignment value.

ToWpf(Thickness)

Convert Ecng.Drawing.Thickness value to Thickness.

public static Thickness ToWpf(this Thickness value)

Parameters

value Thickness

Ecng.Drawing.Thickness value.

Returns

Thickness

Thickness value.

ToWpf(VerticalAlignment)

Convert Ecng.Drawing.VerticalAlignment value to VerticalAlignment.

public static VerticalAlignment ToWpf(this VerticalAlignment value)

Parameters

value VerticalAlignment

Ecng.Drawing.VerticalAlignment value.

Returns

VerticalAlignment

VerticalAlignment value.

ToWpf(Color)

Convert Color value to Color.

public static Color ToWpf(this Color value)

Parameters

value Color

Color value.

Returns

Color

Color value.

ToWpf(PointF)

Convert PointF value to Point.

public static Point ToWpf(this PointF value)

Parameters

value PointF

PointF value.

Returns

Point

Point value.

Try to open the specified link.

public static void TryOpenLink(this string url, DependencyObject owner)

Parameters

url string

Link.

owner DependencyObject

UI thread owner.

TryOpenWithInitialDir(DXFileDialog, DependencyObject, string)

public static bool TryOpenWithInitialDir(this DXFileDialog dlg, DependencyObject owner, string ctrlName)

Parameters

dlg DXFileDialog
owner DependencyObject
ctrlName string

Returns

bool

TryOpenWithInitialDir(DXFolderBrowserDialog, DependencyObject, string)

public static bool TryOpenWithInitialDir(this DXFolderBrowserDialog dlg, DependencyObject owner, string ctrlName)

Parameters

dlg DXFolderBrowserDialog
owner DependencyObject
ctrlName string

Returns

bool

UpdateBrush(DrawingImage, Brush)

public static void UpdateBrush(this DrawingImage source, Brush brush)

Parameters

source DrawingImage
brush Brush

UpdatePen(DrawingImage, Pen)

public static void UpdatePen(this DrawingImage source, Pen pen)

Parameters

source DrawingImage
pen Pen

WpfCast<T>(object)

Cast value to specified type.

public static T WpfCast<T>(this object value)

Parameters

value object

Source value.

Returns

T

Casted value.

Type Parameters

T

Return type.