custom-controls

how to bind collection to custom control in wpf

风格不统一 提交于 2019-12-02 04:19:32
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>())); public ObservableCollection<Subscription> SubscriptionSource { get { return

WPF: IsPressed trigger of ControlTemplate not working

戏子无情 提交于 2019-12-02 03:36:44
问题 I use a custom control named ImageButton to display a button with different images. ImageButton contains dependency properties: public ImageSource DisabledImageSource { get { return (ImageSource)GetValue(DisabledImageSourceProperty); } set { SetValue(DisabledImageSourceProperty, value); } } public ImageSource NormalImageSource { get { return (ImageSource)GetValue(NormalImageSourceProperty); } set { SetValue(NormalImageSourceProperty, value); } } public ImageSource HoverImageSource { get {

How to Access a Button present inside a Custom Control, from the implementing page?

落花浮王杯 提交于 2019-12-02 02:38:19
I have my generic.xaml containing the following code: <ControlTemplate TargetType="local:customVideoControl"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="600"/> <RowDefinition Height="200"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="200"/> <ColumnDefinition Width="200"/> <ColumnDefinition Width="200"/> </Grid.ColumnDefinitions> <MediaElement x:Name="customMediaPlayer" Source="{TemplateBinding CustomMediaSource}" HorizontalAlignment="Center" VerticalAlignment="Center" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}" Grid.Row="0" Grid

Windows Mobile 5 SDK Button Control

ぃ、小莉子 提交于 2019-12-02 01:45:52
问题 I'm a fairly novice programmer working on my first Windows Mobile application. I see that there is no button control available for my program. I've never created a custom control before, and I understand that is the only way that I can get a button for my application (it is a requirement as per my client). I was wondering if someone could give me a quick walk through on how I would create this. I'm using Visual Studio 2005 with the Windows Mobile 5 SDK, creating an application that is to be

Custom Control DataBinding wpf

痴心易碎 提交于 2019-12-02 01:27:27
Currently implementing a custom control I would like to bind some Value directly from my viewModel without using xaml. I can do this: <customControls:MyControl MyValue="{Binding ElementName=MyElem, Path=Text}"> <Textbox Text="{Binding Mytext}" /> But not: <customControls:MyControl MyValue="{Binding MyText}"> The controls is defined in a template and inside the Control code my the MyProperty is defined as: public static readonly DependencyProperty MyValueProperty = DependencyProperty.Register("MyValue", typeof(double), typeof(CustomOEE), new FrameworkPropertyMetadata((Double)20

WPF: IsPressed trigger of ControlTemplate not working

老子叫甜甜 提交于 2019-12-02 00:26:15
I use a custom control named ImageButton to display a button with different images. ImageButton contains dependency properties: public ImageSource DisabledImageSource { get { return (ImageSource)GetValue(DisabledImageSourceProperty); } set { SetValue(DisabledImageSourceProperty, value); } } public ImageSource NormalImageSource { get { return (ImageSource)GetValue(NormalImageSourceProperty); } set { SetValue(NormalImageSourceProperty, value); } } public ImageSource HoverImageSource { get { return (ImageSource)GetValue(HoverImageSourceProperty); } set { SetValue(HoverImageSourceProperty, value);

WPF Custom TextBox with Decimal Formatting

做~自己de王妃 提交于 2019-12-01 23:11:17
I am new to WPF. I have a requirement that I need to develop a custom textbox control which should support the functionality like: Should accept only decimal values. Should round off to 3 decimal places when assigned a value through code or by the user. Should show the full value(without formatting) on focus. Eg: If 2.21457 is assigned to textbox(by code or by user), it should display 2.215. When user clicks in it to edit it, it must show the full value 2.21457. After the user edits the value to 5.42235 and tabs out, it should again round off to 5.422. Tried it without success. So need some

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

天大地大妈咪最大 提交于 2019-12-01 20:27:46
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.DrawString(Me.Text, Me.Font, Brushes.Black, 0, 0) End Sub End Class That works fine. Now I want the

Group properties in a custom control

情到浓时终转凉″ 提交于 2019-12-01 19:28:32
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 EnumEventManagement Automatic Manual End Enum Private mAssociatedControl As MyCustomControl Private mVisibility As

Edittext Fonts Are Not Displaying

元气小坏坏 提交于 2019-12-01 18:56:02
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 CustomEdittext(Context context) { super(context); changeFonts(context); } public CustomEdittext(Context context,