Silverlight中,内网的TextBlock [英] Silverlight, TextBlock inside Grid

查看:93
本文介绍了Silverlight中,内网的TextBlock的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完全新Silverlight和他们给我一个任务来修改它。我的问题很简单(如果在asp.net web表单完成)。
基本上,在网格中,我要追加今年这样的事情。

I'm totally new to silverlight and I was given a task to modify it. My problem is very simple (if done in asp.net webforms). Basically, in the grid, i want to append year to something like this.

Jan + "-" + DateTime.Now.Year.ToString()

Feb + "-" + DateTime.Now.Year.ToString()

etc..etc ..

etc..etc..

在XAML看起来像这样

The xaml looks like this

<Grid x:Name="ContentGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0">
                <Grid.Resources>

<DataTemplate x:Key="mykey1">
                        <Grid >....</Grid>
</DataTemplate>
<DataTemplate x:Key="mykey2">
                        <Grid >....</Grid>
</DataTemplate>
<DataTemplate x:Key="mykey3">
                        <Grid >
<StackPanel Orientation="Vertical">
<Border BorderBrush="{StaticResource LogicaPebbleBlackBrush}" BorderThickness="1">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal" Style="{StaticResource HeaderStackPanel}">


<TextBlock Style="{StaticResource HeaderTextBlock}" Text="Jan-2013" Width="75" TextAlignment="Center"/>
<TextBlock Style="{StaticResource HeaderTextBlock}" Text="Feb-2013" Width="75" TextAlignment="Center"/>


</StackPanel>
</StackPanel>
</Grid>
</DataTemplate>
</ Grid>
</DataTemplate>

我只是想当年动态的,所以它每年的变​​化。请帮助。

I just want to make the year dynamic so it changes yearly. Please help.

推荐答案

我重读你的问题,我认为你需要做这样的事情。
由于您在网格工作有可能命名的TextBlocks。

I reread your question and i think you need to do something like this. Since your are working in a grid it is possible to name your textblocks.

    <TextBlock Style="{StaticResource HeaderTextBlock}" x:Name="JanTB" Width="75" TextAlignment="Center"/>

在你的背后code应该足够放置文本块内的文本。

In your behind code it should be enough to place a text inside the textblock.

    JanTB.Text = "Jan-" + Datetime.now.Year.ToString();

我希望这能解决你的问题。

I hope this solves your question.

这篇关于Silverlight中,内网的TextBlock的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆