473,803 Members | 3,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WPF/Avalon: Adding Controls During Runtime

I have to present inputs (textbox, combobox, etc) that are not known
during design time. In the past this was pretty simple to do. You just
add a new control to the Controls property of a form. How can I
achieve the same thing with WPF?

Thanks

Feb 12 '07 #1
2 7047
<hu*******@yaho o.comwrote in message
news:11******** *************@j 27g2000cwj.goog legroups.com...
>I have to present inputs (textbox, combobox, etc) that are not known
during design time. In the past this was pretty simple to do. You just
add a new control to the Controls property of a form. How can I
achieve the same thing with WPF?

Thanks

Please post XAML, WPF, WCF and WF questions to the msdn forums:

http://forums.microsoft.com/MSDN/def...D=153&SiteID=1

Willy.

Feb 12 '07 #2
You can post these questions to
microsoft.publi c.windows.devel oper.winfx.aval on as well as the MSDN forums
already mentioned since it seems to annoy the C# group to post them there.

As you know (hopefully), the Window has a Content property that can only be
set to one thing. You don't state if your window is blank or already has a
panel or something in it.

If you have a panel, you can just add children to it.

Button btn = New Button();
btn.Content = "Yo Dude"
myStackPanel.Ch ildren.Add(btn) ;

If you have an empty window, you can just set its content:

Button btn = New Button();
Content = btn;

Hope this helps.
Robin S.
-------------------------------------------
<hu*******@yaho o.comwrote in message
news:11******** *************@j 27g2000cwj.goog legroups.com...
>I have to present inputs (textbox, combobox, etc) that are not known
during design time. In the past this was pretty simple to do. You just
add a new control to the Controls property of a form. How can I
achieve the same thing with WPF?

Thanks

Feb 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2321
by: manohar.shankar | last post by:
Hi, I have been searching on this topic for quite sometime and didnt get any answer. Is there a way I can extend/add methods/properties to a C# class during runtime. eg., I have class: public class MyClass {
4
6732
by: Chuck Ritzke | last post by:
Hi, I've searched the newsgroup and other sources to understand how to handle runtime controls and see I'm not the only one who's confused, but I'm still not quite sure of the best way to handle from all the various explanations/answers. I'm attempting the typical scenario... I create a variable number of controls at runtime based on parameters from a database.
4
1977
by: rushikesh.joshi | last post by:
Hi All, I have created my own WebControl and want to add it in my aspx page at runtime. it's compiling perfectly, but when i m going to execute, it gives me error of "Object reference not set to an instance of an object." in my server control (ascx.cs file)
3
1492
by: MikeY | last post by:
Hi everyone, I'm trying to figure out, on my windows form, of what is the best way to add various custom controls at various times during run-time. The problem is that they will need to be in the same spot as each other, depending on what is being called at that particular time by the user. I have been trying to use Inherited user controls, but I am not able, and/or don't know how to retrieve the data from my Inherited user control. If...
1
1340
by: =?Utf-8?B?TWFyaW8=?= | last post by:
hi, i would like to add pictureboxes during runtime, but there should not be a specific variable for each picturebox becouse i don't know how much it will be. so i declared a collection referencing on one var declared as picturebox. it works fine to add the controls this way. now i would like to implement one picturebox click handle for each added picturebox and i have no idea how to do this. Friend WithEvents Device As PictureBox
1
1943
by: ton | last post by:
Hi, I want to add several textbox to my form during runtime: the code is very simple Lab = New TextBox Lab.ID = "A" & i Lab.Height = 200 Lab.Visible = True Lab.Text = "test"
5
4467
by: DBC User | last post by:
I have a situation, where I need to add 4 or 5 data files (they change every time I build) in my project during build time and somehow I need a way to access these files during runtime. So I have 2 questions 1. Is it possible to identify all the files in the resource file during runtime by name of the file? 2. Is it possible to add files to a project at build time to make an exe with those files? Thanks.
2
6229
by: sagarbakliwal | last post by:
hi, I am new to this forum but i have received a lot of help reading through this forum. I am creating a VB.NET application for Patient Record Management. In this there are various combo boxes and buttons being generated during run time when a particular patient ID is searched for. Say one patient might have 2 entries some may have 10 entries. So the controls are generated dynamically and then the control names are added to the forms...
5
3014
by: Dan Tallent | last post by:
I have a scenerio when my forms are first opened that the user cannot modify the data. The fields are disabled to prevent them from modifying any of the data. If a user wishes to modify the data he would be required to click a "Edit" button which will test permissions or status information of the record. If the application determines it is ok for the user to modify the data, it enables the fields where the user now can make changes as...
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9565
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10550
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10317
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.