custom-controls

How can I create subclass of class Inline ? (the one used in FlowDocument)

不羁岁月 提交于 2019-12-04 05:36:52
In WPF I would like to create custom Inline implementation. From documentation of Inline : "An abstract class that provides a base for all inline flow content elements." Classes like Figure , Run or Span inherit from Inline . My custom class inheriting from Inline would be something like '2 lined Run'. I have special needs for flow of document and this seems to be the only way. However I don't know where to start: Inline does not define any members! It is abstract class so it is meant to be inherited but there is no documentation on how to inherit from it. Not in MSDN and nowhere else where I

Creating a WPF Custom Control

北城余情 提交于 2019-12-04 05:19:40
问题 I'm currently creating a user interface using WPF and would like to display a pie-chart on my window. As far as I can see, this will involve creating a custom control - it is not a scenario in which applying styling or templating to an existing control will be sufficient. I've read several articles on custom controls and all of those which provide a detailed description seem to use very different methods. Different authors derive their custom control classes from, among others, Control,

C#: Is it necessary to dispose of a graphics element inside a custom control?

对着背影说爱祢 提交于 2019-12-04 04:46:10
问题 I've created a custom control, overridden it's paint event. When I try to dispose of the graphics I create they just disappear from the screen. Don't I need to use dispose in custom controls? EDIT: I've included a code snippet. Why can't i dispose the dc graphics object, created from the PaintEventArgs? Do i need to dispose it? class canvas : Control { PointF mouseDown; float newX; float newY; float zoomFactor = 1F; Graphics _dc; public canvas() { this.DoubleBuffered = true; mouseDown = new

WPF Validation ErrorTemplate for Custom TextBox

放肆的年华 提交于 2019-12-04 04:43:57
Branching off of this question - When attaching a validation error template to my custom textbox like this - <local:CustomTextBox CustomText="{Binding ViewModelProperty}" Validation.ErrorTemplate="{StaticResource errorTemplate}"/> <ControlTemplate x:Key="errorTemplate"> <DockPanel> <Border BorderBrush="Red" BorderThickness="1"> <AdornedElementPlaceholder x:Name="controlWithError"/> </Border> <TextBlock Foreground="Red" FontSize="20" FontFamily="Segoe UI" Margin="3,0,0,0" MouseDown="Exclamation_MouseDown" Tag="{Binding AdornedElement.(Validation.Errors)[0].ErrorContent, ElementName

vb .NET custom control inheriting from TextBox doesn't fire Paint event

拜拜、爱过 提交于 2019-12-04 04:42:48
问题 I need a multiline TextBox which is always disabled, but it shouldn't paint itself in gray, but I want to keep its designer choosen color. I previously had the same requirement with an always-black Label (no multiline) and so I inherited from Label like: Imports System.ComponentModel Public Class LabelDisabled Inherits Label Sub New() InitializeComponent() Enabled = False End Sub Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) ' always draw it black e.Graphics

XAML binding doesn't seem to set if the property is initialized in the constructor

我与影子孤独终老i 提交于 2019-12-04 04:09:51
I've run into a problem with data-binding inside control template while the property is initialized inside the constructor. Here is the show-case (you can also download sample solution ): CustomControl1.cs public class CustomControl1 : ContentControl { static CustomControl1() { DefaultStyleKeyProperty.OverrideMetadata( typeof(CustomControl1), new FrameworkPropertyMetadata(typeof(CustomControl1))); } public CustomControl1() { Content = "Initial"; // comment this line out and everything // will start working just great } } CustomControl1 style: <Style TargetType="{x:Type local:CustomControl1}">

Group properties in a custom control

五迷三道 提交于 2019-12-04 04:04:35
问题 In our IDE, for example, Visual Studio, if we display the properties of a System.Windows.Forms.Button control, we see some properties that expose anoter set of properties. For example: FlatAppearance, Font, Location, Margin , etcetera. I would like to do something similar in a custom control. I know the code behind is wrong , but here is an example of what I´m trying to do: Public Class StateOfMyCustomControl Public Enum EnumVisibility Visible NonVisible End Enum Public Enum

Can .Net custom controls be used in VB6 form?

删除回忆录丶 提交于 2019-12-04 03:59:14
I am doing some maintenance on a VB6 Windows application. I have a .Net custom control component that I would like to use on a VB6 form. Is this possible? I know how to access non-visual .Net components from VB6 by generating a COM type library for the .Net DLL, but can a .Net custom control be used like a .OCX from VB6? If so, how is the control instantiated in VB6, added to the form, etc. Thanks in advance for any replies. The Interop Forms toolkit will give you what you need: http://msdn.microsoft.com/en-us/vbasic/bb419144.aspx It lets you create UserControls in VB.net which you can then

Edittext Fonts Are Not Displaying

谁都会走 提交于 2019-12-04 03:49:15
问题 I'm going through a weird problem. I have created CustomEdittext class for setting Typeface for whole application and it works successfully in nearly all cases. I am using circo.ttf The problem is that when I set android:inputType="textPassword" , text stops displaying after typing, maybe because the font doesn't have a password symbol or maybe there is some other problem. Below is an example of my issue : CustomEdittext.java public class CustomEdittext extends EditText { public

How Do I Change the render behavior of my custom control from being a span

喜夏-厌秋 提交于 2019-12-04 03:32:04
When writing a custom control it always rendered as an HTML span element. How can I change it for example to a div? Derive your control from WebControl as follows: public class MyCustomControl : WebControl { public MyCustomControl() : base(HtmlTextWriterTag.Div) {} } That is, use the base class constructor that accepts the tag to use. If you derive from CompositeControl there is no constructor that takes a tag type. You can override TagKey (I haven't tried it), but a more flexible option is to override the RenderBeginTag method and make it do what you want. The base class renders a "span"