Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I type cast from string to UIElement

11 views
Skip to first unread message

Rainer Engblom

unread,
Jan 10, 2008, 8:29:01 AM1/10/08
to
Hello,
I have a text file with info about the position of buttons in a grid.
I use FileStream aFile = new FileStream("toolcoordinates.txt", FileMode.Open);
to open the file and read data. I get the buttons as strings, but cannot
find a way to type cast the string to an UIElement. Therefore I cannot place
it in the grid.

I've tried:
(UIElement)'myString'

But it gives me:
Cannot convert type 'string' to 'System.Windows.UIElement'

So, how do I type cast from string to UIElement?

Rainer Engblom

Rainer Engblom

unread,
Jan 10, 2008, 8:37:02 AM1/10/08
to

Actually, type casting is probably not possible, but is there a method of
finding an UIElement, when I have it's name as a string.

Rainer

Rainer Engblom

unread,
Jan 10, 2008, 8:44:03 AM1/10/08
to

Heh, it helps to post here, I found the solution immediately.

It was FindName('myString') as UIElement;

ajay punia

unread,
Aug 11, 2010, 8:22:58 AM8/11/10
to
hi Rainer Engblom,
could you priovide me demo of this uielement storage and getting back into code as a string or uielement ,i am storaing docking state of panes using save and load


>> On Thursday, January 10, 2008 8:37 AM RainerEngblo wrote:

>> Actually, type casting is probably not possible, but is there a method of

>> finding an UIElement, when I have it is name as a string.
>>
>> Rainer
>>
>>
>> "Rainer Engblom" wrote:


>>> On Thursday, January 10, 2008 8:44 AM RainerEngblo wrote:

>>> Heh, it helps to post here, I found the solution immediately.
>>>
>>> It was FindName('myString') as UIElement;
>>>
>>>
>>>
>>>
>>> "Rainer Engblom" wrote:


>>> Submitted via EggHeadCafe - Software Developer Portal of Choice
>>> Win a free Professional license of CodeSmith Generator 5.2!
>>> http://www.eggheadcafe.com/tutorials/aspnet/32aeed64-8518-4bd0-9614-e82b5d3ab3a4/win-a-free-professional-license-of-codesmith-generator-52.aspx

0 new messages