如何为 silverlight 画布设置背景?
我有以下代码,但无法设置画布背景:
<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>
I have the following code but was unable to set background for the 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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设置画布的高度和宽度。
由于您指定了 VerticalAlignment="Top" 和 HorizontalAlignment="Left",画布大小不会在网格中拉伸。
Set your canvas a Height and Width.
Since you specified VerticalAlignment="Top" and HorizontalAlignment="Left" the Canvas size does not stretch in the grid.