usercontrols

Silverlight Popup UserControl - Works once, then crashes

I'm having a go at making a Silverlight2 UserControl to emulate the basic functionality of a WinForms MessageBox. I was following Shawn Wildermuth and John Papa's examples. Compiles fine, I add the user control to my app with a button to show the popup. This works - popup appears, you can click a button to close it and it closes. You ca...

Declaratively set property of MyUserControl in MyUserControl.xaml

Assuming we have such control: public partial class MyUserControl : UserControl { public MyUserControl() { InitializeComponent(); } public string Foo { get; set; } } How can I set "Foo" property value declaratively in MyUserControl.xaml? <UserControl x:Class="Test.MyUserControl" xmlns="http://schemas.microsof...

Refactor XAML code with binding

I try to refactor such XAML by introducing new user control: <Window ...> <ComboBox ItemsSource="{Binding Greetings}" /> </Window> After adding a control I have ControlA XAML: <UserControl ...> <ComboBox ItemsSource="{Binding Items}" /> </UserControl> ControlA C#: public static readonly DependencyProperty ItemsProperty = Wp...

WPF - UserControl default Content attribute

I'm creating a UserControl and I just can't remember the name of the attribute which you use to decorate the property which you want to act as the default content property. To give a concrete example, say i have a property called 'Title' which i can set using property syntax like this - <local:myControl Title="the title"/> But the...

WPF - ItemTemplate not acting as expected.

I have a UserControl which I'm using to display a list of UIElements. The control consists of a single ItemsControl with it's ItemPanelTemplate switched for a horizontal StackPanel, its ItemsSource bound to a DependencyProperty exposed by the UserControl and its ItemTemplate set in the UserControl.Resources. Everything works fine exc...

ContextMenuStrip on User control containing Richtextbox C#

I have made a custom control which consists of a richtextbox and a picture box. Now i want to include a contextmenustrip on the richtextbox actually. But the code which i want to call on click of the different menus on the menustrip belongs to the Main project in which i'l be adding this control. So i thought of adding the contextmenustr...

WPF: Databinding - usercontrol not behaving

I have a little databinding-problem. (I usually have...) This is the error I get in the output window at runtime: System.Windows.Data Error: 39 : BindingExpression path error: 'CurrentKlokke' property not found on 'object' ''UIKlokke' (Name='anaKlokke')'. BindingExpression:Path=CurrentKlokke; DataItem='UIKlokke' (Name='anaKlokke'); tar...

Moving Mac's user settings to another users

I have three new admin users for my Mac: Math, CS and Fun. I would like to move my user settings such as keyboard layout and other config files in the user Masi to other users. I use mostly terminal softwares. How can you move the user settings from one user to other users in Mac Leopard? ...

ASP.Net Custom controls vs. user controls: Are these two the same

If they are different, under what circumstances should we decide to use either approach? Also, what is the advantage of ascx over aspx? ...

WPF - Can't set focus to a child of UserControl

I have a UserControl which contains a TextBox. When my main window loads I want to set the focus to this textbox so I added Focusable="True" GotFocus="UC_GotFocus" to the UserControls definition and FocusManager.FocusedElement="{Binding ElementName=login}" to my main windows definition. In the UC_GotFocus method i simply call .Focus() ...

ClientID inside of ASCX file

So I am trying to get CLientID inside the .ascx (user control mark-up) file. While this My id is: <%=this.ClientID%> renders as My id is: fracTemplateCtrl This: <asp:Button ID="btnSave" runat="server" Text="Save Template" onclick="btnSave_Click" OnClientClick="return confirmSave('<%=this.ClientID%>');" /> renders as (i...

In Web.config Is it possible to register all user controls in specified directory

Currently I'm registering every user control separately in Web.config <pages validateRequest="false"> <controls> <add tagPrefix="cc1" src="~/Controls/MyUserControl1.ascx" tagName="MyUserControl1"/> ... <add tagPrefix="cc1" src="~/Controls/MyUserControlN.ascx" tagName="MyUserControlN"/> </controls> </pages> But from...

C# WPF custom control not responding to XAML properties at design-time?

I've created a UserControl which is essentially a button. It's got an Image and a Label on it and I've created two properties to set the Image's source and the Label's text like so: public ImageSource Icon { get { return (ImageSource)this.GetValue(IconProperty); } set { this.SetValue(IconProperty, value); icon.Source = value; ...

Conflicting RaiseCallbackEvents of ICallbackEventHandler when using a User Control on an ASP.Net Page

Hi and thanks for reading. I am using the ICallbackEventHandler interface to do some client-side processing in an ASP.Net page (VS 2005). Everything works as expected except under the following situation. I created a User Control (.ascx) that also uses ICallbackEventHandler and placed it on the aforementioned ASP.Net page. Now, the R...

Converting a Page to a User Control

Hello, If we want to convert a Page to user control then we should also do the following: “If you aren’t using the code-behind model, make sure you still include a class name in the Control directive by supplying the ClassName attribute. This way, the web page that consumes the control can be strongly typed, which allows it to access p...

Should functionality that's only used once go in a UserControl?

Forgive me if this is a slight mis-use of the system, but I'd like fellow StackOverflow users to settle a debate a colleague and I are having. As a general rule, I prefer each separate item of functionality to be encapsulated within a UserControl even if I know it's only going to be used once. My colleage will eschew creating a UserCon...

SkinID on usercontrol

I have created a usercontrol (a custom button control), how to apply skin on that control. What to write in the skin file for eg for a asp:button i will write <asp:button SkinID ="btnSkinBlue" runat = "server"/>. What to write for a user control? ...

UserControl custom DependencyProperties problem

I have a custom UserControl with an image and a label, both of which are set at design-time in the XAML like so: <controls:HomeBarButton Icon="/SuCo;component/Resources/music.png" Text="music"/> When the control has just an Icon, it looks fine. When I add the Text property, the icon disappears at both design- and run-time and the text l...

.NET Control Events and Page Life Cycle

Here's the problem....I have three components...A Page that contains a User Control and a Server-side control which is in the user control. The user control has a handful of events that the page listens to which change what the server-side control does. The server control essentially creates a TV-Guide looking list filled with many many...

Hosted User Control in IE and Client Side Event Handling

I just upgraded a hosted control to .NET 2.0 and I had to enable the ComVisible to access methods from the client side using javascript. Should events also be accessible once I enable ComVisible? I was handling my events like this before with no issues: <OBJECT id="foo" ...></OBJECT> <script language="javascript"> function docume...