custom-controls

How can data templates in generic.xaml get applied automatically?

两盒软妹~` 提交于 2019-12-07 04:28:00
问题 I have a custom control that has a ContentPresenter that will have an arbitrary object set as it content. This object does not have any constraint on its type, so I want this control to display its content based on any data templates defined by application or by data templates defined in Generic.xaml. If in a application I define some data template(without a key because I want it to be applied automatically to objects of that type) and I use the custom control bound to an object of that type,

UIView with custom shape

强颜欢笑 提交于 2019-12-07 03:11:26
I want to have a UIElement (any of UIView, UIButton, UILabel etc.) with custom shape lets say a triangle. How do you suggest to achieve it. Thanks in advance. Here is a sample of a UIView subclass (triangle): @implementation TriangleView - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code } return self; } - (void)drawRect:(CGRect)rect { // Drawing code CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextBeginPath(ctx); CGContextMoveToPoint (ctx, CGRectGetMinX(rect), CGRectGetMaxY(rect)); // top left CGContextAddLineToPoint(ctx,

How to minimize, maximize and restore down through buttons in java?

五迷三道 提交于 2019-12-07 02:21:41
问题 I'm creating a JavaFX 2.2 program, and need to create custom UI controls (just those ever-present minimize-maximize/restore-close buttons on the top). I need to create custom buttons for that purpose, simple till just creating. I just need the real code for minimize and the maximize/restore buttons (close button was fairly a child's play). The minimize button restores the app to the taskbar. The maximize button, well, maximizes it to fit the user's screen and it toggles to restore button

Wrapped WPF Control

一个人想着一个人 提交于 2019-12-07 02:06:30
I'm trying to create a GUI (WPF) Library where each (custom) control basically wraps an internal (third party) control. Then, I'm manually exposing each property (not all of them, but almost). In XAML the resulting control is pretty straightforward: <my:CustomButton Content="ClickMe" /> And the code behind is quite simple as well: public class CustomButton : Control { private MyThirdPartyButton _button = null; static CustomButton() { DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomButton), new FrameworkPropertyMetadata(typeof(CustomButton))); } public CustomButton() { _button = new

how to change the slider thumb image?

烂漫一生 提交于 2019-12-06 22:40:20
问题 I have to create my own customized slider. I am trying to change the thumb image,background of the slider and in the some test like slide to unlock. I have tried like this but its not working CGRect frame = CGRectMake(0.0, 219.0, 323.0, 20.0); UISlider *myslider = [[UISlider alloc] initWithFrame:frame]; [myslider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged]; [myslider setBackgroundColor:[UIColor clearColor]]; [myslider setThumbImage: [UIImage

Custom Control in WPF as necessary as in Winforms?

て烟熏妆下的殇ゞ 提交于 2019-12-06 22:27:28
During an interview, the company was asking about my use of custom controls in WPF. I have found with all of the power of the WPF way of creating a control (datatemplate, control template, styles,triggers etc... ) that having to write a custom control that overrides the OnRender method really hasn't been necessary. Later found out that most of their development has been in Winforms. If coming at a control from a 100% WPF direction, how often is it necessary to write a customcontrol with OnRender overrides? The Winform approach is really not making use of the WPF composition technique of

How to make a custom progressbar in Android?

≯℡__Kan透↙ 提交于 2019-12-06 21:08:31
问题 What would be the best way to make somthing looking like this: The text on it needs to be customizable, not only numbers, some strings too, depending on context. From what I see it: Create a custom View and within onDraw perform all the calculations and text alignment. Style or extend a horizontal ProgressBar . What do you think ? 回答1: Extend ProgressBar ... override onDraw() The primary reason for this is that all of the primary methods are already there and the first rule of object

Custom Views in the application (Android)

做~自己de王妃 提交于 2019-12-06 21:01:27
I've a drawable for some items like buttons, checkboxes, progress bars and I'd like to define those drawables for beeing the default style of all the buttons my app uses. Is that possible without declaring the style in each View individually? If the answer is to use a Theme for the app I'd appreciate an example (changing the style of all the buttons for example) because I don't understand how to define it. Thanks in advance The answer is to use a theme as you were expecting. Good documentation can be found on android developer site: http://developer.android.com/guide/topics/ui/themes.html For

Images in a WPF Custom Control Library

不羁岁月 提交于 2019-12-06 15:27:40
I need to put an image in the default view of a custom control. However, whenever I try to test the control it can't locate the image. I have tried to compile it as an embedded resource and just a plain resource in VS. Neither of these have worked. So is there a correct way to do this? Sergey Aldoukhov Look at this post: How can I get a BitmapImage from a Resource? That's probably because you specified the image path as a relative path. You should use the Pack URI Scheme to specify that the resource is in the current assembly. For instance : <Image Source="pack://application:,,,/Images/MyImage

Creating custom RichTextBox control

喜欢而已 提交于 2019-12-06 14:18:35
I believe am in need of creating custom RichTextBox in C#. One kind of like that: I admit it might not even have to be RichTextBox , but after some research I decided it's gonna be the easiest way. Functionality I need are icons at each row, checkboxes and text formatting. My program will process each line of the text and mark lines that are correct, incorrect, and strike out lines not necessary in further work, while showing line that's currently processed and allowing user to edit some lines freely (here: lines before Around 3 000 won't be editable, but those under the line will). What's the