WH Xu

WH Xu

  • NA
  • 12
  • 2.5k

I've a question for control's Margin value?

Aug 26 2012 11:06 PM
I use canvas to build a float ,this float can change position of top or bottom with a button.
How can I set and get margin value of canvas?

so poor english..


<StackPanel Height="26" Width="286" Orientation="Horizontal" Margin="0,15,0,0">
<Button  x:Name="btnShowDetail" 
Foreground="White" FontSize="12" 
FontFamily="SimSun" 
BorderThickness="0" Background="{x:Null}" 
Margin="160,0,0,0" HorizontalContentAlignment="Center" BorderBrush="{x:Null}" Padding="0" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseMove">
<i:InvokeCommandAction 
Command="{Binding OnDetailShown}" 
CommandParameter="{Binding ElementName=btnShowDetail}"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave">
<i:InvokeCommandAction
Command="{Binding OnDetailHidden}"
CommandParameter="{Binding ElementName=btnShowDetail}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<Canvas x:Name="grid1" Height="25" Width="82">
<Rectangle x:Name="rectangle"  Height="25"  Width="82" RadiusX="2" RadiusY="2">
<Rectangle.Stroke>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF416693" Offset="1"/>
<GradientStop Color="#FF5E8DC3"/>
</LinearGradientBrush>
</Rectangle.Stroke>
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF5785BB" Offset="0.795"/>
<GradientStop Color="#FF85B7F2"/>
<GradientStop Color="#FF72A2DB" Offset="0.321"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle x:Name="rectangle_Copy" RadiusY="1" RadiusX="1" Fill="{x:Null}" StrokeThickness="1" Stroke="#33FFFFFF" Width="79.916" Height="23.011" VerticalAlignment="Top" Canvas.Left="1.002" Canvas.Top="0.958"/>
<ContentPresenter Content="????"  Canvas.Left="15" Canvas.Top="5"  />
<Canvas x:Name="DetailInfo"
Height="185" 
Width="504" Opacity="1" Visibility="{Binding DetailVisibility}" Canvas.Left="-357.416" Canvas.Top="25" d:LayoutOverrides="Width">
<Path x:Name="rectangle1" Data="M393.74963,0.5 C394.26147,0.49999857 394.77332,0.69526052 395.16385,1.0857825 L400.78177,6.7037086 487.5,6.7037086 C488.60458,6.7037072 489.5,7.5991377 489.5,8.7037096 L489.5,183.70371 C489.5,184.80828 488.60458,185.70371 487.5,185.70371 L2.500001,185.70371 C1.3954304,185.70371 0.5,184.80828 0.5,183.70371 L0.5,8.7037096 C0.5,7.5991377 1.3954304,6.7037072 2.500001,6.7037086 L386.7175,6.7037086 392.33542,1.0857825 C392.72595,0.69526052 393.23779,0.49999857 393.74963,0.5 z" Height="185" Margin="0" Opacity="1" Stretch="Fill" VerticalAlignment="Center" Width="504" Fill="#FFA3ACBE" Stroke="#FF8591AA" Canvas.Top="0"/>
<Path x:Name="rectangle1_Copy" Data="M402.50859,0.5 C403.02043,0.49999857 403.53228,0.69526052 403.92281,1.0857825 L409.54073,6.7037086 498.05107,6.7037086 C499.15565,6.7037072 500.05107,7.5991377 500.05107,8.7037096 L500.05107,184.42294 C500.05107,185.52751 499.55001,185.93535 498.44543,185.93535 L2.6252534,185.93535 C1.5206828,185.93535 0.62525242,185.03992 0.62525242,183.93535 L0.62525242,8.7037096 C0.62525242,7.5991377 1.5206828,6.7037072 2.6252534,6.7037086 L395.47646,6.7037086 401.09438,1.0857825 C401.48491,0.69526052 401.99675,0.49999857 402.50859,0.5 z" Height="183.231" Margin="0" Opacity="1" Stretch="Fill" Width="502.294" Fill="{x:Null}" Stroke="#FFC3C9D5" Canvas.Top="0.855" Canvas.Left="0.996" StrokeThickness="1"/>
<Rectangle Fill="#FFF0F3FA" Height="171" RadiusY="0" RadiusX="0" Stroke="White" Canvas.Top="10.125" Width="496" Canvas.Left="4" StrokeThickness="1"/>
<WrapPanel Height="169" Canvas.Left="5.002" Canvas.Top="11.001" Width="494">
<StackPanel Height="35" Width="328" Orientation="Horizontal" VerticalAlignment="Top" Margin="1,0,0,0">
<TextBlock Margin="5,0,0,0" TextWrapping="Wrap" Text="??????:" Width="Auto" Foreground="#FF8A8A8A" HorizontalAlignment="Left" VerticalAlignment="Stretch" Padding="0,10,0,0" Height="30"/>
<TextBlock Margin="0" TextWrapping="Wrap" Text="{Binding StartTime}" Width="Auto" Foreground="#FF5A5A5A" HorizontalAlignment="Left" VerticalAlignment="Stretch" Padding="0,10,0,0" Height="30" FontWeight="Bold"/>
</StackPanel>
</WrapPanel>
</Canvas>
</Canvas>
</Button>
</StackPanel>