开发者

Content of ContentControl in Resource

I have a ContentControl 开发者_运维技巧in a RadTileView. If I put in some hard coded text into the content property it works fine. (code below)

 <ContentControl Grid.Row="2" Grid.Column="0" Content="Hello World"></ContentControl>

That works...if I put the content into the UserControl.Resources section my application freezes up and displays nothing.

<ContentControl Grid.Row="2" Grid.Column="0" Content="{StaticResource TabControlContent}"></ContentControl>

<UserControl.Resources>
        <TextBlock x:Key="TabControlContent" Text="hello world"></TextBlock>
</UserControl.Resources>

Ultimately I would like to have the context be a RadTabControl..but for now Id settle on just having that textblock render.


To get a string into your ContentControl you would, add

xmlns:sys="clr-namespace:System;assembly=mscorlib"

to your usings. Then add this

<UserControl.Resources>
        <sys:String x:Key="SingleString">Hello World</sys:String>
</UserControl.Resources>

Which would allow

<ContentControl Content="{Binding Source={StaticResource SingleString}}"/>

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜