如何设置silverlight画布的背景?

时间:2010-12-13 13:32:11

标签: silverlight canvas

我有以下代码,但无法为画布设置背景:

<Grid x:Name="LayoutRoot"  >  
  <Canvas Background="SkyBlue"  VerticalAlignment="Top" HorizontalAlignment="Left" >
            <dataInput:Label x:Name="LblOperation" Content="Choose the operation:" Width="200" Height="30"  Canvas.Top="0" Canvas.Left="0"></dataInput:Label>
  <ComboBox Width="100"  Height="20" Canvas.Top="5" Canvas.Left="125">
                <ComboBox.Items >
                    <ComboBoxItem Content="Reconcile" IsSelected="True"></ComboBoxItem>
                    <ComboBoxItem Content="UnReconcile"></ComboBoxItem>
                </ComboBox.Items>
 </ComboBox>
<dataInput:Label x:Name="LblOperationmode" Content="Choose the operation Mode:" Width="200" Height="30"  Canvas.Top="0" Canvas.Left="250"></dataInput:Label>
 <ComboBox Width="125"  Height="20" Canvas.Top="5" Canvas.Left="410">
<ComboBox.Items >
                    <ComboBoxItem Content="Cad Based" IsSelected="True"></ComboBoxItem>
                    <ComboBoxItem Content="SafetyPad Based"></ComboBoxItem>
                </ComboBox.Items>
            </ComboBox>
</canvas>
</grid>

1 个答案:

答案 0 :(得分:3)

将画布设置为高度和宽度。

由于您指定了VerticalAlignment =“Top”和Horizo​​ntalAlignment =“Left”,因此画布大小不会在网格中拉伸。