user-controls

WPF: Custom UserControl that includes a control versus inherits a control

旧时模样 提交于 2020-01-13 18:15:32
问题 I'm creating a UserControl that's a specialized ListBox/View (type not relevant). Now I'm faced with the option to either keep the type as UserControl or Inherit the List control. 1) If I keep it as a UserControl I have a List control inside it and then I have to create a DP for ItemsSource and so on. 2) Let it inherit List control and thus it automatically exposes ItemsSource property. Is either way acceptable or will it become some Code Horror. What is expected. Is there maybe a option 3 I

Why doesn't my jQuery UI datepicker work for postbacks when it works fine on initial page loads?

自古美人都是妖i 提交于 2020-01-13 16:40:51
问题 I've been trying to integrate the jQuery UI Datepicker into our ASP.NET WebForms application. The application uses master pages to provide a common look to all pages, and all of the content pages are built inside the ContentTemplate of an UpdatePanel. I've created a user control to wrap the datepicker's functionality and allow setting of the minDate, maxDate, validators, etc. for each date from the codebehind at runtime. I also need to deal with the way ASP.NET generates client element IDs.

Binding a Textbox to a property in WPF

青春壹個敷衍的年華 提交于 2020-01-13 12:49:28
问题 I have a Textbox in a User Control i'm trying to update from my main application but when I set the textbox.Text property it doesnt display the new value (even though textbos.Text contains the correct data). I am trying to bind my text box to a property to get around this but I dont know how, here is my code - MainWindow.xaml.cs outputPanel.Text = outputText; OutputPanel.xaml <TextBox x:Name="textbox" AcceptsReturn="True" ScrollViewer.VerticalScrollBarVisibility="Visible" Text="{Binding <!--?

How to move WPF UserControl from one window to another?

半城伤御伤魂 提交于 2020-01-13 11:10:55
问题 Let's say I have a UserControl called MyVideoControl located in MainWindow.xaml: <Window Name="_mainWindow"> <Grid> <MyVideoControl Name="_localVideo"/> </Grid> </Window> Now a user clicks a button and I want the UserControl to float on top of the MainWindow.xaml, inside a newly created window called PopUp.xaml. <Window Name="_popUpWindow"> <Grid> <MyVideoControl Name="_localVideo"/> </Grid> </Window> How do I accomplish this, so the entire object gets moved? Currently I use XAML to

Binding UserControl to its own dependencyProperty doesn't work

自作多情 提交于 2020-01-13 05:05:08
问题 Im having a problem where I can't create a User Control which uses properties of an custom object when the parent has set that object to data bind. To try an explain what I mean here is the code. Custom object: public class MyObj { public string Text { get; set; } public MyObj(string text) { Text = text; } } User Control Code Behind: /// <summary> /// Interaction logic for MyControl.xaml /// </summary> public partial class MyControl : UserControl { public static readonly DependencyProperty

Changing the properties of the active control automatically

丶灬走出姿态 提交于 2020-01-12 11:08:30
问题 Please consider that im a newcomer to c#. After scanning about 700 posts i decided to post one more question: On my windows form (c#) I have some controls including textboxes, checkboxes and so on. I want to change the backcolor whenever the controls become active. I know i could raise 'enter' and 'leave' events for each control to change the corresponding properties but there should be another way. 回答1: Simply hook Enter and Leave events - toggling the color in each. Save the last color

ASP.NET - Validating Control Inside UserControl

删除回忆录丶 提交于 2020-01-12 08:26:24
问题 I have a wrapper UserControl control around a DropDownList for managing language specific translation on the DropDownList values. I also have a required field validator that is requried for the inner dropdownlist. How can I expose this control via the usercontrol to allow validation? The error I am currently getting is as follows: ... cannot be validated. at System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty(String name, String propertyName) at System.Web.UI.WebControls

How to Pass a Value From a Window to a UserControl in WPF

末鹿安然 提交于 2020-01-11 11:06:13
问题 I want to pass a value from MainWindow into my UserControl! I passed a value to my UserControl and the UserControl showed me the value in a MessageBox, but it is not showing the value in a TextBox. Here is my code: MainWindow(Passing Value To UserControl) try { GroupsItems abc = null; if (abc == null) { abc = new GroupsItems(); abc.MyParent = this; abc.passedv(e.ToString(), this); } } catch (Exception ee) { MessageBox.Show(ee.Message); } UserControl public partial class GroupsItems :

Passing data between usercontrols c#

蹲街弑〆低调 提交于 2020-01-11 09:44:51
问题 It's known that there are some solutions similar to this one, but I can't solve my problem with them. I have two user controls: The first one makes a Report object. The second one shows it. I have a main Form that links both controls. These two controls are created in a DLL, and are added to the main form like this: //ADDS THE FIRST CONTROL TO THE PANEL CONTROL myDll.controlUserReport userControlA = new myDll.controlUserReport(); panelControl1.Controls.Add(userControlA); userControlA.Dock =

Restrict tab order to a single user control (WPF)

百般思念 提交于 2020-01-11 09:41:28
问题 Currently I have a WPF project with a custom UserControl. This control contains a grid which houses multiple form type elements (checkboxes, textboxes, comboboxes, etc.). The control is designed to look and operate as a form, however it's being placed inside a drag canvas, which is why it needs to be a UserControl and not a window. The issue is the tab navigation between elements needs to be restricted to this control, so when I hit the "Tab" key on the last element in the control, the