custom-controls

DataSource for User Control

故事扮演 提交于 2019-12-09 10:01:46
问题 I am buidling a user control. Currently it consists of a textbox and a button - as a learning experience. This will be used as a basis for a more useful control. I want to add a DataSource, display member and ValueMember. Here is my code for the datasource. It will display in the Properties editor, but is disabled and grayed out. What am I missing? private object MyDataSource; [Browsable(true)] [TypeConverter("System.Windows.Forms.Design.DataSourceConverter")] [System.ComponentModel.Bindable

How to create and use custom control with UpdatePanel added to the page programmatically

天大地大妈咪最大 提交于 2019-12-09 07:21:24
I have simple web user control (the code I found somewhere in the web): <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs" Inherits="ARP.DynamicsCRM2011.MagicWebForm.WebUserControl1" %> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged" Text="Checkbox" /> <asp:Button ID="Button1" runat="server" Text="Button" Visible="False" OnClick="Button1_Click" /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </ContentTemplate> <

Custom Control in ASP.NET C#

冷暖自知 提交于 2019-12-09 04:27:59
问题 I created a simple custom control that only inherits from the Literal control, and doesn't have any extensions yet, code is empty. Namespace: CustomControls Class name: Literal : System.Web.UI.WebControls.Literal Next thing I do is registering this control in the aspx page as following: <%@ Register TagPrefix="web" Namespace="CustomControls" %> (I read in few tutorials that this is one of the ways to register it, besides web.config etc.) After all, no intellisence for me, and worse- I get a

Update all bindings in UserControl at once

丶灬走出姿态 提交于 2019-12-08 17:35:57
问题 I need to update all the bindings on my UserControl when its visibility changes to Visible. Pretty much all my bindings are bound to the DataContext property of the user control so I'm trying to update the target of that binding: BindingOperations.GetBindingExpressionBase(this, UserControl.DataContextProperty).UpdateTarget(); But I get null as the result of GetBindingExpression(..) method and I'm wondering if I'm using this wrong. Also, is there any other good way to refresh all bindings on

WPF Custom Control: DependencyProperty never Set (on only 1 of many properties)

时间秒杀一切 提交于 2019-12-08 17:03:40
问题 I have made a custom control called AddressForm , which inherits from Control. The control is used to display the fields for an IAddress object. Originally I made this control in Silverlight, now I am trying to get it working in WPF .net 4.5 The control defines 9 different dependency properties, and all but one is working correctly. Naturally, the one that is not working is the Address object itself! The Control's Address property never receives a value. I put a break-point in the address's

Access children of Custom Control wpf c#

…衆ロ難τιáo~ 提交于 2019-12-08 14:05:01
问题 Being quite experienced with WPF UserControl , I thought of trying out custom controls. Here's what I have so far : Generic.XAML <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:testapp"> <Style TargetType="{x:Type local:testcontrol}"> <Setter Property="Height" Value="45"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:testcontrol}">

create custom controls mvc3

限于喜欢 提交于 2019-12-08 13:09:05
问题 Just starting to get the hang of MVC3 and want to start building out some custom controls that I can just drop into a view. Specifically I want to be able to drop in some html form controls that will automatically add some javascript for validation. something like this is what I'd want: @Html.VTextBox("MyTextBox","",new {@vType="PhoneNumber", @vMessage="You Must Enter a Phone Number" }) when the page is rendered, I'd want it to search for any custom elements I create then drop in the

Can't deselect buttons using a custom layout

半城伤御伤魂 提交于 2019-12-08 11:48:19
问题 I'm implementing a container with 3 buttons, added dynamically. When I select one, I want that the other ones are deselected (change drawable). This works when I add the buttons directly to a LinearLayout, which I declared in XML. But when I create a custom layout, which extends LinearLayout, and put my buttons there, it doesn't work anymore (although the code is almost the same). I select one button and the code to deselect the other ones is executed, but they still show the drawable of

Where do you set a subview's layer properties? Why not in the initWithCoder

做~自己de王妃 提交于 2019-12-08 10:46:55
问题 I created a custom UITableViewCell (for this example, let's just say the subclass is MyViewCell ) which has an Nib file associated to it MyViewCell.xib . The nib contains a UITableViewCell with one subview UIView (named cardContainer ) that's simply a rectangle with a blue background. I want to add a drop shadow around the UIView , so I added set the layer properties in the -initWithCoder call: @implementation MyViewCell - (id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder

Embed custom control in WPF FlowDocument

巧了我就是萌 提交于 2019-12-08 10:36:03
问题 Is there any way to embed a custom control into the flowdocument and have it correctly displayed by the FlowDocument viewers (export it to Xaml text file and open it by a viewer)? 回答1: If by custom control you mean UserControl or any custom control inherited from a WPF control, you can't: This custom control is in its own XML namespace, and requires code deployed in an assembly. Your XAML reader won't have access to it when attempting to parse the file, and won't succed. You can only use