GVKun编程网logo

什么关键是System.Windows.Input.Key.Clear(什么关键是要发扬彻底的自我革命精神)

14

对于什么关键是System.Windows.Input.Key.Clear感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解什么关键是要发扬彻底的自我革命精神,并且为您提供关于.net–Sys

对于什么关键是System.Windows.Input.Key.Clear感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解什么关键是要发扬彻底的自我革命精神,并且为您提供关于.net – System.Windows.Forms.Keys枚举中的“OEM”密钥是什么?、.net – System.Windows.Input.Key枚举中的Equals键没有条目?、.net – ‘System.Windows.Data.Binding’类型的对象无法转换为’System.String’类型、.net – 为什么Windows服务不能与System.Timers.Timer或System.Windows.Forms.Timer一起正常工作的宝贵知识。

本文目录一览:

什么关键是System.Windows.Input.Key.Clear(什么关键是要发扬彻底的自我革命精神)

什么关键是System.Windows.Input.Key.Clear(什么关键是要发扬彻底的自我革命精神)

我只是意识到在System.Windows.Input.Key中定义了一个明确的键。 但在线帮助只是表示这是“明确的关键”。 没有进一步的信息给出。

谁能告诉我,这个关键是什么,它做了什么?

WIA 2.0双面扫描

包含“distinct()”的EF Query首次缓慢

在Windows平台上的.NET互斥:我完成后会发生什么?

修改创builddate的属性

2应用程序最重要的问题

当Numlock关闭时,它的5个数字键位于另一个箭头的中心。

.net – System.Windows.Forms.Keys枚举中的“OEM”密钥是什么?

.net – System.Windows.Forms.Keys枚举中的“OEM”密钥是什么?

朋友无法找出如何将“Ctrl”指定为ToolStripMenuItem的快捷键。我指出,Keys.OemPlus键将工作,快捷方式的显示字符串需要设置,但是键盘枚举让我感到神秘。

这些“OEM”键有什么处理?我做了一个小小的搜索,似乎是因为键只支持Win2k或更高版本,但这似乎是可笑的,因为我确定人们在Win2k几十年前一直使用plus键。为什么没有“OemEquals”?有没有其他键完全没有在键盘枚举?

我主要寻找一个为什么这些特殊值存在的答案,但我很乐意听到有关其他问题的讨论。可以肯定的是,由于加号在我的键盘上的等号上,使用Keys.OemPlus并检查Shift修饰符键是否可以告诉Ctrl =是否被点击?还有其他键被省略吗?

请注意,这不是一个WPF问题,尽管System.Windows.Forms.Keys和System.Windows.Input.Key枚举看起来是一样的(尽管Key根据框架设计指南错误命名))

它们被引入了Windows API,它们不是WPF的特有的。

首先,这些是KEY代码,而不是字符代码:它们标识键盘上的键,而不是字符。 “A”字符通常按住A键同时按住SHIFT键或使CAPS LOCK有效时生成。

OEM键是与本地键盘不同的按键。美国键盘在括号和括号中,德语键盘具有变音符号。

它们被称为“OEM”,因为原始设备制造商(键盘)负责定义其功能。

.net – System.Windows.Input.Key枚举中的Equals键没有条目?

.net – System.Windows.Input.Key枚举中的Equals键没有条目?

我正在尝试在RoutedUICommand上设置InputGesture,将其挂钩以在用户按下Ctrl =时捕获.我正在使用KeyGesture对象,但我无法在System. Windows.Input.Key枚举中看到equals(‘=’)键的条目.

我期待的是能够做到以下几点:

ZoomIn = new RoutedUICommand("Zoom In","ZoomIn",typeof(Window),new InputGestureCollection { 
        new KeyGesture(Key.Equals,ModifierKeys.Control) 
    });

有人能指出我正确的方向吗?

正如克里斯夫所指出的那样,我需要让我的大脑有点活跃.对于它的价值,处理KeyDown事件时生成的值是Key.OemPlus.

更新:
这样做的一个结果是,如果你和我做同样的事情并且你将在菜单中使用该命令,你可能想要使用重载的构造函数来获取带有displayString的第3个参数的KeyGesture.例如:

new KeyGesture(Key.Equals,ModifierKeys.Control,"Ctrl+=")

否则,您将看到键盘快捷键显示为(在我的情况下)“Ctrl OemPlus”,这不是完全合乎需要的.不可否认,上面仍然不是很好,但它比“OemPlus”更好.

.net – ‘System.Windows.Data.Binding’类型的对象无法转换为’System.String’类型

.net – ‘System.Windows.Data.Binding’类型的对象无法转换为’System.String’类型

我想知道是否有人可以帮忙.我现在已经半天不停地反对这个问题了,我一定是做错了.我有一个具有许多依赖项属性的自定义控件.

[TemplatePart(Name = informationBubble.informationBubbleTitlePart,Type = typeof(TextBlock))]
[TemplatePart(Name = informationBubble.informationBubbleProductimagePart,Type=typeof(Image))]

public class informationBubble : Control 
{
    #region Template Parts Name Constants

    /// <summary>
    /// Name constant for the information Bubble Title Part
    /// </summary>
    public const string informationBubbleTitlePart = "informationBubbleTitleText";

    /// <summary>
    /// Name constant for the information Bubble Product Image Part
    /// </summary>
    public const string informationBubbleProductimagePart = "informationBubbleProductimage";

    #endregion

    #region TemplateParts

    private TextBlock _Title;

    internal TextBlock Title
    {
        get { return _Title; }
        private set
        {
            _Title = value;

            if (_Title != null)
            {
                _Title.Text = this.ProductTitleText;       
            }
        }
    }

    private Image _Productimage;

    internal Image Productimage
    {
        get { return _Productimage; }
        private set
        {
            _Productimage = value;

            if (_Productimage != null)
            {
                _Productimage.source = this.ProductimageSource;
            }
        }
    }

    #endregion

    #region Public String Product Title 

    // Dependency properties declaration
    public static readonly DependencyProperty ProductTitleProperty = DependencyProperty.Register(
        "ProductTitle",typeof(string),typeof(informationBubble),new PropertyMetadata(string.Empty,new PropertyChangedCallback(OnProductTitleChanged)));

    public static void OnProductTitleChanged(DependencyObject sender,DependencyPropertyChangedEventArgs e)
    {
        informationBubble iBubble = sender as informationBubble;

        if (iBubble.Title != null)
        {
            iBubble.Title.Text = e.NewValue as string;
        }
    }

    public string ProductTitleText
    {
        get { return GetValue(ProductTitleProperty) as string; }
        set { SetValue(ProductTitleProperty,value); }
    }

    #endregion

    #region Public Image Source Product Image

    public static readonly DependencyProperty ProductimageSourceProperty = DependencyProperty.Register(
        "ProductimageSource",typeof(ImageSource),new PropertyMetadata(null,new PropertyChangedCallback(OnProductimageSourceChanged)));

    public static void OnProductimageSourceChanged(DependencyObject sender,DependencyPropertyChangedEventArgs e)
    {
        informationBubble iBubble = sender as informationBubble;

        if (iBubble.Productimage != null)
        {
            iBubble.Productimage.source = e.NewValue as ImageSource;
        }
    }

    public ImageSource ProductimageSource
    {
        get { return GetValue(ProductimageSourceProperty) as ImageSource; }
        set { SetValue(ProductimageSourceProperty,value); }
    }

    #endregion

    public informationBubble()
    {
         this.DefaultStyleKey = typeof(informationBubble);
    }

    #region Overrides

    public override void OnApplyTemplate()
    {       
        base.OnApplyTemplate();

        Title = GetTemplateChild(informationBubble.informationBubbleTitlePart) as TextBlock;
        Productimage = GetTemplateChild(informationBubble.informationBubbleProductimagePart) as Image;
    }

    #endregion

    #region Private Methods

    private void GoToState(string stateName,bool useTransitions)
    {
        visualstatemanager.GoToState(this,stateName,useTransitions);
    }

    #endregion
}

现在,如果我在我的xaml中的某个地方使用此控件,那么如果我执行此操作:

<controls:informationBubble 
        ProductimageSource="{Binding SelectedItem.normalImageSource}"
        ProductTitleText="Test Title"
        "/>

但是,如果我尝试将数据绑定到viewmodel中的SelectedItem对象的title属性的数据:

<controls:informationBubble 
            ProductimageSource="{Binding SelectedItem.normalImageSource}"
            ProductTitleText="{Binding SelectedItem.Title,Mode=TwoWay"
            "/>

我得到’System.Windows.Data.Binding’类型的对象不能转换为’System.String’类型. TextBlock的text属性是DependencyProperty,所​​以我必须在这里遗漏一些明显的东西.

非常感谢任何帮助或见解.

短剑的一种

解决方法

可能是该物业的名称是错误的.下面代码中的“ProductTitle”应该是“ProductTitleText”吗?

public static readonly DependencyProperty ProductTitleProperty = DependencyProperty.Register(
    "ProductTitle",// "ProductTitleText" ?
    typeof(string),new PropertyChangedCallback(OnProductTitleChanged)));

我想当你使用字符串常量时,WPF使用反射直接访问属性“public string ProductTitleText”. DependencyProperty被忽略,因为属性的名称不匹配(“ProductTitle”与“ProductTitleText”).

因此,对于标题,您有一个名为“ProductTitle”的依赖项属性和一个名为“ProductTitleText”的(字符串)属性.
对于Productimage,您有一个名为“ProductimageSource”的依赖项proeprty和一个名为“ProductimageSource”的属性(ImageSource类型).

是否有意义?

.net – 为什么Windows服务不能与System.Timers.Timer或System.Windows.Forms.Timer一起正常工作

.net – 为什么Windows服务不能与System.Timers.Timer或System.Windows.Forms.Timer一起正常工作

我最近遇到了编写Windows服务的挑战.我需要定期请求URL并检查其可用性.为此,我决定在服务的OnStart方法中初始化一个计时器,并在timer_Tick事件中完成所有工作.

我的第一种方法是使用System.Windows.Forms.Timer及其Tick事件.我选择了它,因为我正在阅读的教程.不知怎的,我无法使服务工作.它安装并启动没有问题,但它不会触发事件(我将调试器附加到进程并看到它没有被触发).我认为在Windows服务中使用Forms计时器可能不是一个好主意,因此我决定切换到System.Timers.Timer并利用其Elapsed事件.这也不起作用.我在Windows窗体应用程序中尝试了两种提到的方法,但它们都有效.

经过一番挖掘后,我发现这个网站:http://weblogs.asp.net/sibrahim/archive/2004/01/13/58429.aspx,博主建议使用另一个计时器:System.Threading.Timer.我第三次改变了这种方法,BOOM开始像魅力一样工作.

我的问题是:为什么我不能在Windows服务中使用其他计时器,为什么找到有关它的信息这么困难?

System.Windows.Forms.Timer计时器使用UI的消息泵来编组tick事件,默认情况下服务不运行消息泵,因此没有一点额外的工作,System.Windows.Forms.Timer计时器将不会工作.

System.Timers.Timer是一个基于服务器的计时器,并在您创建它的线程上引发一个事件(我认为).如果这不起作用,也许你没有启动计时器或计时器在一个立即结束的线程上运行(因为,没有任何东西保持线程活着,所以它完成).

http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx

System.Threading.Timer计时器使用在ThreadPool线程上运行的回调,并且根本不依赖于消息泵,因此这有效.

当您在WinForms项目中运行Application.Run(myForm)时,该调用也会运行消息泵,这将管理UI消息.您提到的Windows计时器是一个UI组件,并期望消息泵运行,以便在UI线程上发生tick事件.

看看这里在Windows服务中运行消息泵:

Message pump in .NET Windows service

进一步阅读:

http://support.microsoft.com/kb/842793

总之,我只是使用System.Threading.Timer类.

关于什么关键是System.Windows.Input.Key.Clear什么关键是要发扬彻底的自我革命精神的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于.net – System.Windows.Forms.Keys枚举中的“OEM”密钥是什么?、.net – System.Windows.Input.Key枚举中的Equals键没有条目?、.net – ‘System.Windows.Data.Binding’类型的对象无法转换为’System.String’类型、.net – 为什么Windows服务不能与System.Timers.Timer或System.Windows.Forms.Timer一起正常工作的相关知识,请在本站寻找。

本文标签: