11433 : Position texts before and and after a time item


Howto get textblocks to appear before and after the TimeItem?


In this time item the Grid with name Rect is the one that gets the size based on Start and Stop datetime values.

The Text after the time item is the one named Text1, the one infront is Text2.

Text1 is positioned in the event implementation: SizeChanged=”TimeItem_SizeChanged” see impl at the bottom

Text2 is positioned with a Translate transform with a negative value.

        <DataTemplate x:Name=”SquaredTimeItem”>< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

            <l:TimeItem Height=”20″

                Start=”{Binding Start,Mode=TwoWay}”

                Stop=”{Binding Stop,Mode=TwoWay}”

                Identity=”{Binding Id}”

                TimeItemSizedFrameworkElementName=”Rect” SizeChanged=”TimeItem_SizeChanged”>


                <Grid Height=”20″ Name=”Rect”>

                    <Border  BorderBrush=”Black” BorderThickness=”0″ CornerRadius=”3″>




                                    <GradientStop Offset=”0″ Color=”LightGray”/>

                                    <GradientStop Offset=”1″ Color=”Gray”/>






                <TextBlock Name=”Text1″ HorizontalAlignment=”Right” Margin=”3,6,0,0″ Text=”{Binding To}” >


                                <TranslateTransform X=”20″></TranslateTransform>



                <TextBlock Name=”Text2″ HorizontalAlignment=”Left” Margin=”3,6,0,0″ Text=”{Binding From}” >                           


                                <TranslateTransform X=”-25″></TranslateTransform>







        private void TimeItem_SizeChanged(object sender, SizeChangedEventArgs e)


            if (sender is TimeItem)


                TextBlock tb1=(sender as TimeItem).FindName(“Text1”) as TextBlock;

                (tb1.RenderTransform as TranslateTransform).X = e.NewSize.Width + 10;




Leave a Reply