custom-controls

.NET WinForms Custom Control: how to get a reference to the containing form

北城余情 提交于 2019-12-24 05:06:10
问题 Is there a way, when creating a WinForms Custom Control/User Control, to get a reference at runtime to the form the control is placed on, so as to access various properties of that form? I would rather not pass a reference to the form into the constructor of the control, as, for various reasons, I need to keep a default constructor with no parameters. One example: I have several Custom Controls that encapsulate Win32 API calls, and some of the calls require Window handles to be passed as

Binding doesn't work when using custom control in DataTemplate

主宰稳场 提交于 2019-12-24 04:53:22
问题 I'm trying to replace a standard control inside ListView DataTemplate with a custom control, but binding doesn't seem to work properly. Here is the definition of the ListView: <Grid> <ListView ItemsSource="{Binding DataItemsCollection}"> <ListView.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="Static text" /> <TextBlock Text="{Binding DataItemText}" /> <BindingTest:CustomControl CustomText="{Binding DataItemText}" /> </StackPanel> </DataTemplate> </ListView.ItemTemplate> <

Custom Checkbox style for WPF

笑着哭i 提交于 2019-12-24 03:34:08
问题 I would like to skin a wpf default checkbox to something custom. Since it does not really make sense to start off a entirely new control, i'd like to override the Windows Chrome template binding for the Bulletchrome sub component of the checkbox. However I cannot do this like I can with checkboxes for example. tried using something like this to override the default style, but it seems to not compile like this <Style x:Key="cb_BULLETSTYLE" TargetType="{x:Type BulletDecorator}"> <Setter

.NET Windows Forms custom designer doesn't refresh the menu

我与影子孤独终老i 提交于 2019-12-24 02:45:10
问题 I have created a custom designer ( PannelloSfondoDesigner ) for my custom control, a background panel ( PannelloSfondo ). <Designer(GetType(PannelloSfondo.PannelloSfondoDesigner))> Public Class PannelloSfondo Inherits UserControl Friend Class PannelloSfondoDesigner Inherits ParentControlDesigner Public Overrides Sub Initialize(ByVal component As IComponent) MyBase.Initialize(component) verbDock = New DesignerVerb("Dock to parent container", New EventHandler(AddressOf Me.OnDock)) verbUndock =

How can I add InputScope property to PasswordBox in WinRT?

被刻印的时光 ゝ 提交于 2019-12-24 00:57:05
问题 How can I add Input Scope property to my User Control's PasswordBox? Could you explain it to me, please? Thanks. 回答1: according to the information i have PasswordBox does not have Input Scope Property in winrt so you can't set it directly. if you want do it you have to make your separate custom control. For defining your own Custom control you have read it on Windows Development Center ..or simply google it..hope it helps you.. you can use this link.. 来源: https://stackoverflow.com/questions

How to prevent Enter press from closing menu

旧时模样 提交于 2019-12-24 00:45:08
问题 I'm embedding a Colour Picker into a Context Menu using the Windows.Forms.ToolStripControlHost class. The picker displays fine and handles all mouse events properly: The problem arises when one of the channel sliders is double clicked. This causes the control to add a Windows.Forms.TextBox into the parent control with the same dimensions as the slider so users can enter numeric values. When Enter is pressed while the TextBox has focus, it should assign the value and hide the textbox (which it

placing widget in listbox/dropdown in gwt

点点圈 提交于 2019-12-23 23:15:19
问题 i am using gwt to build my web site. i would like to create a dropdown/listbox that contains no just text but also images, meaning that in the drop down there will be a what ever widget that ill create. please advise jaimon 回答1: You won't be able to do this with a ListBox, because it just creates an HTML < select> element. You can use a MenuBar that has one menu with MenuItems in it to simulate a dropdown with complex widgets inside it. You will also be able to style the dropdown rather than

Xamarin Custom View Button Binding

点点圈 提交于 2019-12-23 20:44:46
问题 I have a custom view with 2 button in it - One on the left and one on the right. I want to have a bindable property to dictate which function will be called by each button, but the function I want to call is in the original content page, not the custom control. I'm aware that you can't have a void as the bindable property so I'm not sure how to achieve this. Here's my custom control xaml: <?xml version="1.0" encoding="UTF-8"?> <RelativeLayout xmlns="http://xamarin.com/schemas/2014/forms"

WPF custom slider drawed by yourself

谁说胖子不能爱 提交于 2019-12-23 18:14:51
问题 This is my first question on stack-overflow so don't kick it)) I have a problem trying to create a Mac-style slider control. I have found this solution and I have implemented it in my solution, but it still doesn't satisfy me cause I need a more universal solution. Basically I need to create this slider control with the help of four pictures - right, left and center(the rest of) pictures of track bar and one picture for thumb. These are PNG files. Could I style default WPF slider to support

C# FontFamily not showing new fonts

久未见 提交于 2019-12-23 16:27:41
问题 I notice that when we are trying to list fonts using C#, that it works fine; however, if we are to install a new font while the application is running, calling the enumeration of fonts doesn't return the new font, until the application is restarted. Here's the code: public void Populate(bool b) { both = b; foreach (FontFamily ff in FontFamily.Families) { if(ff.IsStyleAvailable(FontStyle.Regular)) Items.Add(ff.Name); } } Notes for the above method: Items.Add() is adding items to a comboBox . I