custom-controls

How to display caret in custom WPF text box

我只是一个虾纸丫 提交于 2019-12-13 08:01:58
问题 I have designed my own text box in WPF by creating my own custom control template. However, I cannot seem to get the caret to show up. Here is my TextBox style: <Style TargetType="{x:Type TextBox}"> <Setter Property="SnapsToDevicePixels" Value="True"/> <Setter Property="OverridesDefaultStyle" Value="True"/> <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/> <Setter Property="FocusVisualStyle" Value="{x:Null}"/> <Setter Property="AllowDrop" Value="True"/> <Setter Property=

How do I make an custom drawn resizable container?

我只是一个虾纸丫 提交于 2019-12-13 06:34:30
问题 I have a WinForms gui application which has a number of areas to it which I'd like to custom-draw some graphics. These areas would contain controls and be resizeable. I'm currently thinking of inheriting from a TableLayoutPanel and handling onpaint messages. Does this sound like a good way to go or are there other/better options? 回答1: Any Windows Forms control has a Paint event, you don't have to derive your own class. But sure, you can, it helps partitioning the code. Just pick a base class

Battery consumption with custom animated drawable

可紊 提交于 2019-12-13 06:10:04
问题 Loooong time viewer, finally getting round to signing up here at StackOverflow! After a very long time searching for a way to do a scrolling background of a ViewGroup in Android, I've developed the following: public class SlidingDrawable extends Drawable implements Drawable.Callback { private static final String TAG = "SlidingDraw"; private static float STEP_SIZE = 1.0f; private BitmapDrawable mBitmap; private Context mContext; private float mPosX; private int mBitmapWidth; private Runnable

Adding custom labels in NSIS dialog pages, showing and hiding labels in NSIS MUI Directory pages conditionally, how to get the ids of labels

折月煮酒 提交于 2019-12-13 05:16:55
问题 How to hide a Custom LABEL added on the Directory Page Dialog of the NSIS installer. The LABEL is added using the Resource Hacker and its id is 1300 How to change the text of the LABEL conditionally? If user choses to install DEMO, then the label text should be "DEMO" , and if user choses to install UPDATE , then the label text should be "UPDATE" I have added 2 labels, now i am hiding and showing them accordingly.Label1 ID is 1300 , Label2 ID is 1301. # Occurs on Directory page show. Function

Declaring custom controls

£可爱£侵袭症+ 提交于 2019-12-13 04:47:57
问题 I'm going to use a bunch of controls that each consist of a label and a text box. Is it a good idea to declare a custom control so that in encapsulates both the caption of the label and the input area of the text box as one? I can probably inherit and create something in C# but the point here is to get better at XAML so the approach of declaring such a thingy (not sure if it's called resource, template, style or anything else) by a markup is to be preferred (if not yet necessary). At the

Avoid frequent updates in WPF custom control

白昼怎懂夜的黑 提交于 2019-12-13 04:42:20
问题 I am writing a custom control in WPF. The control have several properties that cause update of the control's logical tree. There are several methods of this form: private static void OnXXXPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { ((MyControl)obj).RebuildTree(); } Suppose the RebuildTree() method is very complex and lenghty and if users changes several properties, this method is called several times causing application slowdown and hanging. I would like to

ComboBox SelectedValue not changing from binding to Dependency Property

非 Y 不嫁゛ 提交于 2019-12-13 04:39:59
问题 I have a Custom Control: I don't want to get into specifics so for simplicity's sake i have 3 Dependency Properties : MyCustomControl (CS) : public class MyCustomControl : Control { DP Value1 DP InternalValue DP SelectedValue OnValue1Changed() { InternalValue = CalculateBasedOn1(); } static bool _isSetInternally; OnInternalValueChanged() { if(Condition()) { _isSetInternally = true; SelectedValue = e.NewValue; } else { Value1 = FixValue1(); } } OnSelectedValueChanged() { if(_isSetInternally) {

Error: “ 'Subjects' property was already registered by 'Period' ” is raised when more than one control is placed on the form

主宰稳场 提交于 2019-12-13 04:30:20
问题 As you can see in the code below I have created a custom control named Period that inherits from Listbox. In it I have declared a read-only dependancy property named 'Subjects'. When a single Period is placed on the WPF window everything runs fine. However, when I place more than one I get the error mentioned in the title. Here is the Period Class: Public Class Period Inherits System.Windows.Controls.ListBox '-------- PROPERTIES --------' Public ReadOnly Property Subjects() As

How to create curved UIButton for iPhone application

爷,独闯天下 提交于 2019-12-13 04:24:15
问题 I want to create UIButtons which are curved. For demo look at this image. I don't want to create the exact buttons, but they will have curve like this buttons. Is it possible to create such buttons in iOS? Thank you. 回答1: Have a look at OBShapedButton, its a UIButton subclass for non-rectangular shapes. 来源: https://stackoverflow.com/questions/16419151/how-to-create-curved-uibutton-for-iphone-application

Custom scrollable layout with default values

懵懂的女人 提交于 2019-12-13 04:23:54
问题 I'm trying to make custom RelativeLayout inside ScrollView. Now I have to copy this part of code in every place where I want to use it: <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="xxx" android:layout_height="yyy"> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top" android:layout_margin="@dimen/card_margin" android