本文整理汇总了C#中System.Windows.Window.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Window.SetValue方法的具体用法?C# Window.SetValue怎么用?C# Window.SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Window
的用法示例。
在下文中一共展示了Window.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnregisterWindowUsingAttachedProperty
public void UnregisterWindowUsingAttachedProperty()
{
// ARRANGE
var window = new Window();
window.SetValue(DialogServiceViews.IsRegisteredProperty, true);
// ACT
window.SetValue(DialogServiceViews.IsRegisteredProperty, false);
// ASSERT
Assert.That(DialogServiceViews.Views, Is.Empty);
}
示例2: AttachWindowListeners
private static void AttachWindowListeners(Window window, object vm) {
if(vm != null) {
var listener = new WindowMessageListener(window);
window.SetValue(WindowMessageListenerProperty, listener);
listener.Attach(vm, window);
window.DataContextChanged += window_DataContextChanged;
}
}
示例3: DettachWindowListeners
private static void DettachWindowListeners(Window window, object vm) {
if(vm != null) {
var listener = (WindowMessageListener)window.GetValue(WindowMessageListenerProperty);
if(listener != null) {
window.SetValue(WindowMessageListenerProperty, null);
listener.Dettach(vm, window);
}
}
}
示例4: capture
public bool capture(String path)
{
try
{
Thread newWindowThread = new Thread(new ThreadStart(() =>
{
// Create and show the Window
mainWindow = new Window();
this.path = path;
this.makeDir();
Rectangle resolution = Screen.PrimaryScreen.Bounds;
mainWindow.WindowState = WindowState.Maximized;
mainWindow.WindowStyle = WindowStyle.None;
mainWindow.BorderThickness = new Thickness(0);
mainWindow.SizeToContent = SizeToContent.WidthAndHeight;
//mainWindow.SetValue() = new ScaleTransform()
mainWindow.SetValue(Window.LayoutTransformProperty, null);
//Generate Canvas
canvas = new Canvas();
canvas.Width = resolution.Width;
canvas.Height = resolution.Height;
canvas.Background = getImageBrush();
mainWindow.Content = canvas;
mainWindow.MouseDown += new System.Windows.Input.MouseButtonEventHandler(mouseDown);
mainWindow.MouseMove += new System.Windows.Input.MouseEventHandler(mouseMove);
mainWindow.MouseUp += new System.Windows.Input.MouseButtonEventHandler(mouseUp);
// always on top
mainWindow.Topmost = true;
mainWindow.Show();
// Start the Dispatcher Processing
System.Windows.Threading.Dispatcher.Run();
}));
newWindowThread.SetApartmentState(ApartmentState.STA);
// Make the thread a background thread
newWindowThread.IsBackground = true;
// Start the thread
newWindowThread.Start();
CaptureTool.captureResetEvent.WaitOne();
}
catch(Exception)
{
}
return true;
}
示例5: EnsureHotkeyServiceHelper
private static HotkeyServiceHelper EnsureHotkeyServiceHelper(Window window)
{
HotkeyServiceHelper helper = (HotkeyServiceHelper)window.GetValue(HotkeyServiceHelperPropertyKey.DependencyProperty);
if (helper == null)
{
helper = new HotkeyServiceHelper(window);
window.SetValue(HotkeyServiceHelperPropertyKey, helper);
}
return helper;
}
示例6: _EnsureAttachedExtensions
private static WindowExtensions _EnsureAttachedExtensions(Window window)
{
Assert.IsNotNull(window);
var ext = (WindowExtensions)window.GetValue(WindowExtensionsProperty);
if (ext == null)
{
ext = new WindowExtensions(window);
window.SetValue(WindowExtensionsProperty, ext);
}
return ext;
}
示例7: SetPinned
private static void SetPinned(Window window, bool value)
{
var interopHelper = new WindowInteropHelper(window);
var handle = interopHelper.Handle;
if (handle == IntPtr.Zero)
{
window.SetValue(IsPinnedProperty, value);
window.Loaded += WindowLoaded;
return;
}
if (value)
PinToDesktop(handle);
else
UnpinFromDesktop(handle);
}
示例8: RegisterWindowUsingAttachedProperty
public void RegisterWindowUsingAttachedProperty()
{
// ARRANGE
var window = new Window();
var expected = new[]
{
new ViewWrapper(window)
};
// ACT
window.SetValue(DialogServiceViews.IsRegisteredProperty, true);
// ASSERT
Assert.That(DialogServiceViews.Views, Is.EqualTo(expected));
}
示例9: SetDialogResult
public static void SetDialogResult(Window target, bool? value)
{
target.SetValue(DialogResultProperty, value);
}
示例10: EnsureWindow
/// <summary>
/// Makes sure the view is a window is is wrapped by one.
/// </summary>
/// <param name="model">The view model.</param>
/// <param name="view">The view.</param>
/// <param name="isDialog">Whethor or not the window is being shown as a dialog.</param>
/// <returns>The window.</returns>
protected virtual Window EnsureWindow(object model, object view, bool isDialog)
{
var window = view as Window;
if (window == null) {
window = new Window {
Content = view,
SizeToContent = SizeToContent.WidthAndHeight
};
window.SetValue(View.IsGeneratedProperty, true);
var owner = InferOwnerOf(window);
if (owner != null)
{
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
window.Owner = owner;
}
else
{
window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
}
}
else
{
var owner = InferOwnerOf(window);
if (owner != null && isDialog)
window.Owner = owner;
}
return window;
}
示例11: SetIsEnabled
public static void SetIsEnabled(Window window, bool value) {
window.SetValue(IsEnabledProperty, value);
}
示例12: SetSettings
public static void SetSettings(Window element, Settings value)
{
element.SetValue(SettingsProperty, value);
}
示例13: SetIsHiddenCloseButton
private static void SetIsHiddenCloseButton(Window obj, bool value)
{
obj.SetValue(IsHiddenCloseButtonKey, value);
}
示例14: SetIsClosingAsPartOfDragOperation
internal static void SetIsClosingAsPartOfDragOperation(Window element, bool value)
{
element.SetValue(IsClosingAsPartOfDragOperationProperty, value);
}
示例15: SetHasMaximizeButton
public static void SetHasMaximizeButton(Window element, bool value)
{
element.SetValue(ControlBox.HasMaximizeButtonProperty, value);
}