We can set a margin to an annotation.
authorcavaliet
Wed, 16 Sep 2009 19:32:26 +0200
changeset 71 31900a35e162
parent 70 4a2f4b9e971a
child 72 f1ca0958c992
child 74 7ce946833eae
We can set a margin to an annotation.
src/FingersDance.Views/TimelineAnnotationView.xaml
src/FingersDance.Views/TimelineAnnotationView.xaml.cs
--- a/src/FingersDance.Views/TimelineAnnotationView.xaml	Wed Sep 16 17:46:19 2009 +0200
+++ b/src/FingersDance.Views/TimelineAnnotationView.xaml	Wed Sep 16 19:32:26 2009 +0200
@@ -6,9 +6,13 @@
 	xmlns:Custom="http://schemas.microsoft.com/surface/2008"
 	mc:Ignorable="d"
 	x:Class="FingersDance.Views.TimelineAnnotationView"
+    xmlns:vw="clr-namespace:FingersDance.Views"
 	x:Name="UserControl"
 	d:DesignWidth="640" d:DesignHeight="480">
-    <Grid x:Name="LayoutRoot" Margin="0,0,0,0">
+    <UserControl.Resources>
+        <vw:ThicknessSingleValueConverter x:Name="myThicknessSingleValueConverter" x:Key="myThicknessSingleValueConverter"></vw:ThicknessSingleValueConverter>
+    </UserControl.Resources>
+    <Grid x:Name="LayoutRoot" Margin="{Binding Path=TcBegin, Converter={StaticResource myThicknessSingleValueConverter}}">
         <Rectangle Fill="Green" HorizontalAlignment="Left" VerticalAlignment="Top" Width="4" Height="20"/>
         <TextBox Text="{Binding Path=GestureType}" Width="100" Margin="5,0,0,0"/>
     </Grid>
--- a/src/FingersDance.Views/TimelineAnnotationView.xaml.cs	Wed Sep 16 17:46:19 2009 +0200
+++ b/src/FingersDance.Views/TimelineAnnotationView.xaml.cs	Wed Sep 16 19:32:26 2009 +0200
@@ -24,4 +24,20 @@
             InitializeComponent();
         }
     }
+
+    public class ThicknessSingleValueConverter : IValueConverter
+    {
+        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+        {
+            ThicknessConverter myThicknessConverter = new ThicknessConverter();
+            Thickness th1 = (Thickness)myThicknessConverter.ConvertFrom(value);
+            th1.Top = th1.Top;
+            return th1;
+        }
+        public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
+        {
+            Thickness thickness = (Thickness)value;
+            return thickness.Left;
+        }
+    }
 }