Class XamlHelper
public static class XamlHelper
- Inheritance
-
XamlHelper
- Inherited Members
Fields
DialogResultProperty
public static readonly DependencyProperty DialogResultProperty
Field Value
DisabledCommand
Disabled command.
public static readonly ICommand DisabledCommand
Field Value
Properties
CurrentThreadDispatcher
public static Dispatcher CurrentThreadDispatcher { get; }
Property Value
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
objectAny 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
HorizontalAlignmentHorizontalAlignment value.
Returns
- HorizontalAlignment
Ecng.Drawing.HorizontalAlignment value.
FromWpf(Brush)
Convert Brush value to DrawingBrush.
public static Brush FromWpf(this Brush value)
Parameters
Returns
- Brush
DrawingBrush value.
FromWpf(Color)
public static Color FromWpf(this Color value)
Parameters
Returns
FromWpf(Point)
public static PointF FromWpf(this Point value)
Parameters
Returns
FromWpf(Thickness)
Convert Thickness value to Ecng.Drawing.Thickness.
public static Thickness FromWpf(this Thickness value)
Parameters
Returns
- Thickness
Ecng.Drawing.Thickness value.
FromWpf(VerticalAlignment)
Convert VerticalAlignment value to Ecng.Drawing.VerticalAlignment.
public static VerticalAlignment FromWpf(this VerticalAlignment value)
Parameters
value
VerticalAlignmentVerticalAlignment value.
Returns
- VerticalAlignment
Ecng.Drawing.VerticalAlignment value.
GetActiveOrMainWindow(Application)
public static Window GetActiveOrMainWindow(this Application app)
Parameters
app
Application
Returns
GetActiveWindow(Application)
public static Window GetActiveWindow(this Application app)
Parameters
app
Application
Returns
GetActiveWindows(Application)
public static IEnumerable<Window> GetActiveWindows(this Application app)
Parameters
app
Application
Returns
GetActualSize(FrameworkElement)
public static (int width, int height) GetActualSize(this FrameworkElement elem)
Parameters
elem
FrameworkElement
Returns
GetBrush(DrawingImage)
public static Brush GetBrush(this DrawingImage source)
Parameters
source
DrawingImage
Returns
GetDialogResult(DependencyObject)
Boilerplate code to register attached property "bool? DialogResult"
public static bool? GetDialogResult(DependencyObject obj)
Parameters
obj
DependencyObject
Returns
- bool?
GetImage(string, SolidColorBrush, SolidColorBrush)
Get colored icon.
public static ImageSource GetImage(this string iconKey, SolidColorBrush fill, SolidColorBrush stroke = null)
Parameters
iconKey
stringKey.
fill
SolidColorBrushFill brush.
stroke
SolidColorBrushStroke brush.
Returns
- ImageSource
Icon.
GetImage(FrameworkElement)
public static BitmapSource GetImage(this FrameworkElement elem)
Parameters
elem
FrameworkElement
Returns
GetImage(Visual, int, int)
public static BitmapSource GetImage(this Visual visual, int width, int height)
Parameters
Returns
GetImage(Visual, (int width, int height))
public static BitmapSource GetImage(this Visual visual, (int width, int height) size)
Parameters
Returns
GetWindow(DependencyObject)
public static Window GetWindow(this DependencyObject obj)
Parameters
obj
DependencyObject
Returns
GuiAsync(Dispatcher, Action)
public static void GuiAsync(this Dispatcher dispatcher, Action action)
Parameters
dispatcher
Dispatcheraction
Action
GuiAsync(Dispatcher, Action, DispatcherPriority)
public static void GuiAsync(this Dispatcher dispatcher, Action action, DispatcherPriority priority)
Parameters
dispatcher
Dispatcheraction
Actionpriority
DispatcherPriority
GuiAsync(DispatcherObject, Action)
public static void GuiAsync(this DispatcherObject obj, Action action)
Parameters
obj
DispatcherObjectaction
Action
GuiSync(Dispatcher, Action)
public static void GuiSync(this Dispatcher dispatcher, Action action)
Parameters
dispatcher
Dispatcheraction
Action
GuiSync(Dispatcher, Action, DispatcherPriority)
public static void GuiSync(this Dispatcher dispatcher, Action action, DispatcherPriority priority)
Parameters
dispatcher
Dispatcheraction
Actionpriority
DispatcherPriority
GuiSync(DispatcherObject, Action)
public static void GuiSync(this DispatcherObject obj, Action action)
Parameters
obj
DispatcherObjectaction
Action
GuiSync<T>(Dispatcher, Func<T>)
public static T GuiSync<T>(this Dispatcher dispatcher, Func<T> func)
Parameters
dispatcher
Dispatcherfunc
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
Dispatcherfunc
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
DispatcherObjectfunc
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
GuiThreadGetAsync(Func<CancellationToken, Task>, CancellationToken)
public static Task GuiThreadGetAsync(Func<CancellationToken, Task> func, CancellationToken token)
Parameters
func
Func<CancellationToken, Task>token
CancellationToken
Returns
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
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
MakeHideable(Window)
public static void MakeHideable(this Window window)
Parameters
window
Window
ReColor(SvgImage, Color?, Color?)
Change SVG image stroke/fill colors. Original is not changed.
public static SvgImage ReColor(this SvgImage orig, Color? stroke, Color? fill)
Parameters
Returns
- SvgImage
SaveImage(BitmapSource, Stream)
public static void SaveImage(this BitmapSource image, Stream file)
Parameters
image
BitmapSourcefile
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
DependencyObjectproperty
DependencyPropertydataObject
objectpath
stringmode
BindingModeconverter
IValueConverterparameter
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
DependencyObjectproperty
DependencyPropertydataObject
objectpath
PropertyPathmode
BindingModeconverter
IValueConverterparameter
object
SetDialogResult(DependencyObject, bool?)
public static void SetDialogResult(DependencyObject obj, bool? value)
Parameters
obj
DependencyObjectvalue
bool?
SetMultiBinding(DependencyObject, DependencyProperty, IMultiValueConverter, params Binding[])
public static void SetMultiBinding(this DependencyObject obj, DependencyProperty prop, IMultiValueConverter conv, params Binding[] bindings)
Parameters
obj
DependencyObjectprop
DependencyPropertyconv
IMultiValueConverterbindings
Binding[]
ShowModal(CommonDialog, DependencyObject)
public static bool ShowModal(this CommonDialog dlg, DependencyObject obj)
Parameters
dlg
CommonDialogobj
DependencyObject
Returns
ShowModal(CommonDialog, Window)
public static bool ShowModal(this CommonDialog dlg, Window owner)
Parameters
dlg
CommonDialogowner
Window
Returns
ShowModal(Window)
public static bool ShowModal(this Window wnd)
Parameters
wnd
Window
Returns
ShowModal(Window, DependencyObject)
public static bool ShowModal(this Window wnd, DependencyObject obj)
Parameters
wnd
Windowobj
DependencyObject
Returns
ShowModal(Window, Window)
public static bool ShowModal(this Window wnd, Window owner)
Parameters
Returns
ShowModel<TWindow>(object, DependencyObject)
public static bool ShowModel<TWindow>(this object model, DependencyObject owner) where TWindow : Window, new()
Parameters
model
objectowner
DependencyObject
Returns
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
Streamoptions
BitmapCreateOptionscache
BitmapCacheOptionfreeze
bool
Returns
ToColor(int)
public static Color ToColor(this int color)
Parameters
color
int
Returns
ToInt(Color)
public static int ToInt(this Color color)
Parameters
color
Color
Returns
ToSvg(Stream)
Convert stream to SVG image.
public static ImageSource ToSvg(this Stream stream)
Parameters
Returns
- ImageSource
SVG image.
ToTransparent(Color, byte)
public static Color ToTransparent(this Color color, byte alpha)
Parameters
Returns
ToWpf(Brush)
Convert DrawingBrush value to Brush.
public static Brush ToWpf(this Brush value)
Parameters
value
BrushDrawingBrush value.
Returns
ToWpf(HorizontalAlignment)
Convert Ecng.Drawing.HorizontalAlignment value to HorizontalAlignment.
public static HorizontalAlignment ToWpf(this HorizontalAlignment value)
Parameters
value
HorizontalAlignmentEcng.Drawing.HorizontalAlignment value.
Returns
ToWpf(Thickness)
Convert Ecng.Drawing.Thickness value to Thickness.
public static Thickness ToWpf(this Thickness value)
Parameters
value
ThicknessEcng.Drawing.Thickness value.
Returns
ToWpf(VerticalAlignment)
Convert Ecng.Drawing.VerticalAlignment value to VerticalAlignment.
public static VerticalAlignment ToWpf(this VerticalAlignment value)
Parameters
value
VerticalAlignmentEcng.Drawing.VerticalAlignment value.
Returns
ToWpf(Color)
public static Color ToWpf(this Color value)
Parameters
Returns
ToWpf(PointF)
public static Point ToWpf(this PointF value)
Parameters
Returns
TryOpenLink(string, DependencyObject)
Try to open the specified link.
public static void TryOpenLink(this string url, DependencyObject owner)
Parameters
url
stringLink.
owner
DependencyObjectUI thread owner.
TryOpenWithInitialDir(DXFileDialog, DependencyObject, string)
public static bool TryOpenWithInitialDir(this DXFileDialog dlg, DependencyObject owner, string ctrlName)
Parameters
dlg
DXFileDialogowner
DependencyObjectctrlName
string
Returns
TryOpenWithInitialDir(DXFolderBrowserDialog, DependencyObject, string)
public static bool TryOpenWithInitialDir(this DXFolderBrowserDialog dlg, DependencyObject owner, string ctrlName)
Parameters
dlg
DXFolderBrowserDialogowner
DependencyObjectctrlName
string
Returns
UpdateBrush(DrawingImage, Brush)
public static void UpdateBrush(this DrawingImage source, Brush brush)
Parameters
source
DrawingImagebrush
Brush
UpdatePen(DrawingImage, Pen)
public static void UpdatePen(this DrawingImage source, Pen pen)
Parameters
source
DrawingImagepen
Pen
Url2Img(Uri)
public static ImageSource Url2Img(this Uri uri)
Parameters
uri
Uri
Returns
WpfCast<T>(object)
Cast value to specified type.
public static T WpfCast<T>(this object value)
Parameters
value
objectSource value.
Returns
- T
Casted value.
Type Parameters
T
Return type.