Click here to Skip to main content
12,826,621 members (23,698 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# WPF C#4.0
hello every body....
i have a tag textbox in my project!
i want every time my user clicks on button or "ENTER" a text block show up and contain it's textblock.text content's!!
then i want to in another page's, when user look's at details of a product, some textblock's with tag's on'em show up....
i want to customize the size of the text's to show the one's with more similar tag's( like one tag has been used 5 time's! must be bigger than a tag with 2 time's of use!!
data base has been done! but how can i make the textblock's in runtime?!
Posted 12-Oct-12 9:47am
Wes Aday 12-Oct-12 14:49pm
The same way you do everything else! Textblock tb = new Textblock();!!
Wes Aday 12-Oct-12 14:57pm
The exact same way you do for everything else... What exactly does LINQ have to do with anything in your question?
Sergey Alexandrovich Kryukov 12-Oct-12 14:57pm
Exactly. I have my method of learning concrete things and explaining to CodeProject members how to do it. Please see my answer -- very general and robust approach... :-)
senaps 12-Oct-12 15:04pm
i think i just got confused!! when i look at the answer, i just want to shoot myself!! how did i forget that thing?!!
maybe i thought there is a simpler way to do that! i was scared of it's margin and... to write them in my own!
thanks man...
senaps 12-Oct-12 15:06pm
yea.... i had done it for making messageboxes! and button's!!! but didn't really remember it since last 5 hour's!!
but i agree... i' gonna check to do some project's in you way...that help's me alot if don't forget'em.... must write some new cheat paper!
Sergey Alexandrovich Kryukov 12-Oct-12 15:19pm
This is easy enough, not to worry. Thanks for accepting this solution.
Good luck, call again.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

All controls are always added during run time, anyway. You don't see it directly only because you add some controls (or all of them) in XAML, and the actual "adding" code is not shown to you as the source code, because the real source is XAML. But you don't think they are added my some mystical "force", do you? :-)

Here is what happens: you author layout in XAML, and, during the build, the actual code is first generated using the XAML, compiled in a usual way and used by application.

So, now you want to do some of such code with your own hands? Right, there are many cases when you really need it; and XAML is just awkward to use or does not provide enough expressing capabilities. There is a lot of code which cannot be expressed in XAML.

So, here is my, very general advice which will cover many similar questions. First, try to do what you need in a simplified sample, in XAML, in some temporary prototype application. Build it. Find auto-generated C# files — if will find them in directory structure under the location of the project file. Load the files and see how things work in C#. Learn it and then use in your work.

Simple and general, isn't it? This approach never failed. :-)

Good luck,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170326.1 | Last Updated 12 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100