custom-controls

WPF: A TextBox that has an event that fires when the Enter Key is pressed

让人想犯罪 __ 提交于 2019-12-02 16:46:17
Instead of attaching a PreviewKeyUp event with each TextBox in my app and checking if the pressed key was an Enter key and then do an action, I decided to implement extended version of a TextBox that includes a DefaultAction event that fires when an Enter Key is pressed in a TextBox . What I did was basically create a new Class that extends from TextBox with a public event DefaultAction , like such: public class DefaultTextBoxControl:TextBox { public event EventHandler<EventArgs> DefaultAction = delegate { }; public DefaultTextBoxControl() { PreviewKeyUp += DefaultTextBoxControl_PreviewKeyUp;

Propagate ListBoxItem IsSelected trigger to child control

人盡茶涼 提交于 2019-12-02 13:16:01
I'm developing a CheckedListBox with self removable ListBoxItem s. The problem is that an item only gets checked if the user clicks on the CheckBox area, which is kind of awkward. How do I create ListBoxItem triggers ( IsSelected ) to check the checkboxes on a "DataSourced" ListBox ? Eg: Below is my control (all other code have been omitted for brevity): <ListBox x:Name="executors" ItemsSource="{Binding Executors}" HorizontalAlignment="Left" Height="121" Margin="23,19,0,0" VerticalAlignment="Top" Width="362"> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property=

how to bind collection to custom control in wpf

倾然丶 夕夏残阳落幕 提交于 2019-12-02 12:39:54
问题 I am building a custom control and I want to pass a collection to it so that control display that collection, my code is as the following : <gm:Calendar SubscriptionSource="{Binding Subscriptions}"></gm:Calendar> and in Custom control "Calendar" public static readonly DependencyProperty SubscriptionSourceProperty = DependencyProperty.Register( "SubscriptionSource", typeof(ObservableCollection<Subscription>), typeof(Calendar), new FrameworkPropertyMetadata(new ObservableCollection<Subscription

Custom FXML component (w/ controller) doesn't appear in SceneBuilder's “Import jar” dialog

蓝咒 提交于 2019-12-02 12:38:05
问题 I am following this in creating a custom component and importing it. However, when it gets to the Import Dialog after clicking the jar file, it does not appear. When I comment out the code the tutorial used for the constructor, it appears again. However, none of the subcomponents I used to make the custom one appear. Why and how do I fix it? Also, I am using a VBox instead of an AnchorPane (as seen in the tutorial) for my own thing. Code of constructor as seen in tutorial: public

Override AutoSize for derived Label Control in C#

守給你的承諾、 提交于 2019-12-02 11:36:18
I am trying to extend the System.Windows.Forms.Label class to support vertically drawn text. I do this by creating a new property called MyLabelOrientation that the user can set to Horizontal or Vertical. When the user changes this setting, the values for width and height are swapped to resize the control to its new orientation. Finally, I override the OnPaint function to draw my Label. I would like to extend the AutoSize property for this control as well so that my Label will auto-size to the text it contains. For the horizontal orientation, the base functionality implements this for me. For

custom attribute on custom Button does not show

女生的网名这么多〃 提交于 2019-12-02 10:24:47
I extended the Button widget to be able to apply several custom attributes. One of the attributes is a color filter I try to apply to its background when the button is created. It does not work. (See the screen shots and code below) I tried to directly set the background color, on the same code place, and it does change the background color, but it is not what I need, since I am using my own button PNGs. there are 2 problems so far: The color filter is not applied The custom button is offset, clipped and it is not clickable The second button uses the normal button, and it is positioned as

How to make a control to be painted/refreshed properly

眉间皱痕 提交于 2019-12-02 10:11:20
I have a control derived from checkbook which I called "SettingBooleanButton", but when any window or dialog is dragged over the control the control keeps signs of the drag The next image shows the effect of dragging an application window over control This is the code block that I have for OnPaint() Public Class SettingBooleanButton Inherits CheckBox Private _settingSection As String Private _settingName As String Private _associatedSetting As Setting Public Event StateChange(ByVal affectedSetting As Setting) Sub New() ' This call is required by the designer. InitializeComponent() ' Add any

Wpf ListBox – change default selected-item style *inside* the ContentPresenter

喜你入骨 提交于 2019-12-02 09:57:48
I have a ListBox in which each item is a StackPanel. The StackPanel consist of an Image and a TextBlock below it: <ListBox.ItemTemplate> <DataTemplate> <StackPanel Margin="10"> <Image> <Image.Source> <BitmapImage UriSource="{Binding Path=ImageFilePath}"/> </Image.Source> </Image> <TextBlock Text="Title" TextAlignment="Center"/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> It looks like this: When the user select an item, I get the default blue rectangle that surround the StackPanel: Now, I want to make a different border for the selected-item, but I want it to surround only the image

C# WinForm custom grid layout [closed]

▼魔方 西西 提交于 2019-12-02 08:39:58
I need to create a list of objects that has a custom layout like this: would you please tell me ho to implement it in the winform c# application? Note that the data can not bind from a database directly and it should fill in the code. Thanks Wael's answer does indeed show you the recommended way: Create a UserControl and add it either to a FlowLayoutPanel or to a TableLayoutPanel . One thing about UserControls does require some attention: All the controls you add to it are private and can't be accessed easily, even when you add the UC to a Form in the designer.. So you should either change

Click-to-Edit Control LostFocus event issue

前提是你 提交于 2019-12-02 08:13:23
I am working on a simple Custom Control that should go to Edit mode by double clicking on it The concept is based on this question Click-to-edit in Silverlight On a double click it changes initial template on Edit Template and it seems to be pretty clear, except the part (5) How to change the template Back when the Control Looses the focus The Lost Focus event is fired only when contained controls are loosing focus Here is an article that talk about it http://programmerpayback.com/2008/11/20/gotfocus-and-lostfocus-events-on-containers/ I have tried to implement same Technic but still no result