No, Just ignore that you are using Silverlight and think of the basics of XML. In your first example, LinkLabel.Text is an element and you are trying to set the innter text to "test". In the second one, you are setting the value of the "Text" attribute
to "test". The parser must treat these completely differently.
Todd
If this post answered your question, please mark as answered.
But it takes this instead of Width="150":
<local:LinkLabel>
<local:LinkLabel.Width>
150 <-- this works, sets the width of control to 150
</local:LinkLabel.Width>
</local:LinkLabel>
So I guess I'm missing something in making a custom element do the same.
Just found out that ContentProperty is bugged. So chalk it up as another "fixed in RTM".
They REALLY need to have a Silverlight bug list and fix list or something. I've seen people in here spend DAYS on something, just to find out it's a Beta 2 bug. Ditto with this thing.
Hey Todd. The link to the project is at the very bottom of the first post. In the project it sets the Text field in C#, but I needed it to be in Xaml for ease of use. Thus trying to shove text directly into the controls Xaml insides, or via a .Text element
inside said control.
sladapter
All-Star
43609 Points
7910 Posts
Re: Re: How to create a control with string as direct content?
Sep 22, 2008 08:40 PM | LINK
He wants to put the content as string in between the control's beginTag and EndTag. But in Silverlight that's not valid XAML:
You can do this:
<Button Content="Button"/>
or this:
<Button><TextBlock Text="Button"/></Button>
But you can not do this:
<Button>Button<Button>
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
Harlequin
Member
218 Points
159 Posts
Re: Re: How to create a control with string as direct content?
Sep 22, 2008 09:05 PM | LINK
If I can't put a direct string in, which I now understand, why doesn't this work:
<local:LinkLabel>
<local:LinkLabel.Text>
test
</local:LinkLabel.Text>
</local:LinkLabel>
When the attribute works:
<local:LinkLabel Text="test" />
Are they not the same?
Todd Herman
Member
626 Points
126 Posts
Re: Re: How to create a control with string as direct content?
Sep 22, 2008 09:14 PM | LINK
No, Just ignore that you are using Silverlight and think of the basics of XML. In your first example, LinkLabel.Text is an element and you are trying to set the innter text to "test". In the second one, you are setting the value of the "Text" attribute to "test". The parser must treat these completely differently.
Todd
Todd Herman
http://blogs.thecodearchitects.com
Harlequin
Member
218 Points
159 Posts
Re: Re: How to create a control with string as direct content?
Sep 22, 2008 09:58 PM | LINK
But it takes this instead of Width="150":
<local:LinkLabel>
<local:LinkLabel.Width>
150 <-- this works, sets the width of control to 150
</local:LinkLabel.Width>
</local:LinkLabel>
So I guess I'm missing something in making a custom element do the same.
Todd Herman
Member
626 Points
126 Posts
Re: Re: How to create a control with string as direct content?
Sep 22, 2008 10:07 PM | LINK
Good point. I have never used Width in that manner. I will play with it a little and see if I can come up with something.
Todd
Todd Herman
http://blogs.thecodearchitects.com
Harlequin
Member
218 Points
159 Posts
Re: Re: How to create a control with string as direct content?
Sep 24, 2008 02:27 PM | LINK
Just in case someone Googles this thread.
Just found out that ContentProperty is bugged. So chalk it up as another "fixed in RTM".
They REALLY need to have a Silverlight bug list and fix list or something. I've seen people in here spend DAYS on something, just to find out it's a Beta 2 bug. Ditto with this thing.
Todd Herman
Member
626 Points
126 Posts
Re: Re: How to create a control with string as direct content?
Sep 24, 2008 02:51 PM | LINK
If you can send me a short project that tests what you are trying to accomplish I can test it for you to ensure it has been fixed in RTM.
Todd Herman
http://blogs.thecodearchitects.com
sladapter
All-Star
43609 Points
7910 Posts
Re: Re: How to create a control with string as direct content?
Sep 24, 2008 03:02 PM | LINK
You could test this simple Xaml, currently this is invalid even Button has Content property:
<Button>Test</Button>
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
Harlequin
Member
218 Points
159 Posts
Re: Re: How to create a control with string as direct content?
Sep 24, 2008 03:39 PM | LINK
Hey Todd. The link to the project is at the very bottom of the first post. In the project it sets the Text field in C#, but I needed it to be in Xaml for ease of use. Thus trying to shove text directly into the controls Xaml insides, or via a .Text element inside said control.
Todd Herman
Member
626 Points
126 Posts
Re: Re: How to create a control with string as direct content?
Sep 24, 2008 04:10 PM | LINK
Doh! Sorry about that. I see the link now. I will check it out as soon as I get home this afternoon.
Todd Herman
http://blogs.thecodearchitects.com