Tag: 自定义控件

Visual Studio 2008 IDE无法正确呈现自定义控件

我在设计时遇到了Visual Studio 2008中所有表单和自定义控件的问题。直到上一次检入,所有控件都按预期呈现。 当前版本和上一个工作版本之间唯一的主要区别是控件UIText上的属性已从Content重命名为Value 。 其他更改是添加一个新表单和3个新枚举,但肯定没有明显的变化会影响程序中的所有表单(包括新表单)。 所有控件(在每个窗体上)现在都呈现为一个带有控件名称的框(但它们都在运行时正确呈现): 我已经尝试在我的项目中创建一个全新的表单,创建一个全新的自定义控件,上面只有一个标签,我仍然有完全相同的问题: 请注意,标准.Net表单控件工作正常,因此这只是自定义控件的问题。 如果我从存储库中恢复以前的版本,那么一切都会再次开始正确呈现: 我可以恢复到这个工作版本并继续,但我宁愿知道如果它再次发生如何解决问题。 我在这里发帖,希望它是一个与Visual Studios 2008问题相关的编程问题(顺便提一下SP1)。 更新 – 问题跟踪,无法解释 我解决了这个问题。 好吧,固定不是真正合适的词。 我通过一次删除所有用户控件1找到问题,直到表单再次正确开始渲染。 这个问题出现在我的Signature控件中(已存在多年,只有在我最近的检查中,我已将项目iVirtualDocket.CodeLibrary的引用添加到主项目中: iVirtualDocket – References iVirtualDocket.UIControls – References iVirtualDocket.CodeLibrary iVirtualDocket.UIControls -References iVirtualDocket.CodeLibrary 签名有一个名为SignatureData的属性,它正在这样做: public byte[] SignatureData { get { if (_signature == null) { return null; } else { return iVirtualDocket.CodeLibrary.Conversions.ImageToByteArray( _signature, ImageFormat.Png); } } } […]

控件的自定义设计器

我有一个派生自SplitContainer的自定义类: namespace Builder.Components { public partial class ProjectSidebar : SplitContainer { public ProjectSidebar() { InitializeComponent(); } } } 现在,当我右键单击并选择View Designer时,我希望看到SplitContainer并对其进行编辑,就像我使用默认控件一样(在其中放置一个面板等)。 我看到的只是添加控件和切换到代码视图的消息 。 怎么做到这一点?

用户控件的数据源

我正在建立一个用户控件。 目前它由一个文本框和一个按钮组成 – 作为一种学习体验。 这将用作更有用的控制的基础。 我想添加一个DataSource,显示成员和ValueMember。 这是我的数据源代码。 它将显示在“属性”编辑器中,但已禁用并显示为灰色。 我错过了什么? private object MyDataSource; [Browsable(true)] [TypeConverter(“System.Windows.Forms.Design.DataSourceConverter”)] [System.ComponentModel.Bindable(true)] public object DataSource { get { return MyDataSource; } set { if (MyDataSource != value) MyDataSource = value; } }

使用C#和UI Automation来获取未知控件类型的内容

在下图中,有一个区域,其中包含一个未知(自定义)类。 这不是网格或表格。 我需要能够: 选择此区域的行 从每个单元格中获取值 问题是,因为这不是一个常见的类型元素 – 我不知道如何谷歌这个问题或自己解决它。 到目前为止,代码如下: Process[] proc = Process.GetProcessesByName(“programname”); AutomationElement window = AutomationElement.FromHandle(proc [0].MainWindowHandle); PropertyCondition xEllist2 = new PropertyCondition(AutomationElement.ClassNameProperty, “CustomListClass”, PropertyConditionFlags.IgnoreCase); AutomationElement targetElement = window.FindFirst(TreeScope.Children, xEllist2); 我已经尝试将此区域作为文本框,作为网格,作为combobox来威胁,但到目前为止还没有解决我的问题。 有没有人有任何建议如何从这个区域获取数据并迭代行? 编辑:抱歉,我做了一个错误的假设。 实际上,这个区域的标题(第1列,第2列,第3列)和“下半部分”是不同的控制类型 !! 感谢Wininspector,我能够挖掘有关这些控件类型的更多信息: 标头具有以下属性:HeaderControl 0x056407DC(90441692)Atom:#43288 0xFFFFFFFF(-1) 下半部分有:ListControl 0x056408A4(90441892)primefaces:#43288 0x02A6FDA0(44498336) 我之前展示的代码 – 仅检索“List”元素,所以这里是更新: Process[] proc = Process.GetProcessesByName(“programname”); AutomationElement window = AutomationElement.FromHandle(proc [0].MainWindowHandle); //getting […]

创建自定义全尺寸日历控件

如何在更大的视图中创建显示日历控件的自定义控件。 像这样或喜欢outlook 2007中的日历视图。我是否必须创建自定义类,或者我可以尝试调整日历大小。 我在WPF中这样做,所以我使用WPF Toolkit

WPF:一个TextBox,它有一个按下Enter键时触发的事件

我没有在我的应用程序中为每个TextBox附加PreviewKeyUp事件并检查按下的键是否为Enter键然后执行操作,而是决定实现包含DefaultAction事件的TextBox扩展版本,该事件在按下Enter键时触发在TextBox 。 我所做的基本上是创建一个新的类,它使用公共事件DefaultAction从TextBox扩展,如下所示: public class DefaultTextBoxControl:TextBox { public event EventHandler DefaultAction = delegate { }; public DefaultTextBoxControl() { PreviewKeyUp += DefaultTextBoxControl_PreviewKeyUp; } void DefaultTextBoxControl_PreviewKeyUp(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key != Key.Enter) { return; } DefaultAction(this, EventArgs.Empty); } } 然后我使用我的应用程序中的这个自定义文本框(如xaml): 现在,在我学习WPF的过程中,我已经意识到几乎大部分时间都有一种“更酷”(并且希望更容易)实现的方式 …所以我的问题是, 我怎样才能改善上述控制? 或者是否有另一种方法可以进行上述控制? …也许只使用声明性代码而不是声明性(xaml)和程序性(C#)?

Click-to-Edit控制LostFocus事件问题

我正在开发一个简单的自定义控件,它应该通过双击进入编辑模式 该概念基于Silverlight中的点击编辑问题 双击它会更改编辑模板上的初始模板,它似乎很清楚,除了部分(5)如何更改模板返回当控件失去焦点时失去焦点事件仅在包含的控件失去焦点时触发这是一篇关于它的文章http://programmerpayback.com/2008/11/20/gotfocus-and-lostfocus-events-on-containers/ 我试图实现相同的Technic但仍然没有结果,当我点击控件外部时,我无法让LostFocus事件为我工作 我的问题在哪里? 我的XAML <!—-> 代码背后 using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace Splan_RiaBusinessApplication.Controls { public class TimeCode { public int TimeCodeId {get;set;} public string Code { get; set; } public […]

WPF:ControlTemplate的IsPressed触发器无法正常工作

我使用名为ImageButton的自定义控件来显示具有不同图像的按钮。 ImageButton包含依赖项属性: public ImageSource DisabledImageSource { get { return (ImageSource)GetValue(DisabledImageSourceProperty); } set { SetValue(DisabledImageSourceProperty, value); } } public ImageSource NormalImageSource { get { return (ImageSource)GetValue(NormalImageSourceProperty); } set { SetValue(NormalImageSourceProperty, value); } } public ImageSource HoverImageSource { get { return (ImageSource)GetValue(HoverImageSourceProperty); } set { SetValue(HoverImageSourceProperty, value); } } public ImageSource PushedImageSource { get { return (ImageSource)GetValue(PushedImageSourceProperty); […]

OwnerDraw ComboBox不再“样式化”了

我用DrawMode = OwnerDrawVariable创建了一个自定义combobox。 一切都很好,除了它不再使用DropDownList模式中的视觉样式,即它看起来像旧的combobox。 如何使用视觉样式绘制它? 我检查了VisualStyleElement类,但没有找到任何可以帮助我的东西。 这是否意味着不能使用视觉样式绘制OwnerDrawcombobox???

如何从实现页面访问自定义控件内的按钮?

我的generic.xaml包含以下代码: 现在在applyTemplate上,我正在访问如下控件: public override void OnApplyTemplate() { base.OnApplyTemplate(); ToggleButton playPauseBtn = GetTemplateChild(“playPauseBtn”) as ToggleButton; Button prevBtn= GetTemplateChild(“prevBtn”) as Button; Button nextBtn = GetTemplateChild(“nextBtn”) as Button; MediaElement customMediaPlayer = GetTemplateChild(“customMediaPlayer”) as MediaElement; playPauseBtn.Checked += (obj, Args) => { customMediaPlayer.Pause(); playPauseBtn.Content = “Play”; }; playPauseBtn.Unchecked += (obj, Args) => { customMediaPlayer.Play(); playPauseBtn.Content = “Pause”; }; nextBtn.Click += […]