2010-11-01 21 views
0

我有一個圖像覆蓋在散點圖項目上。 scatterview項目包含堆疊面板和幾個文本塊。在將主窗口的背景重疊並且透明的情況下,我仍然可以看到與圖像不吻合的角落。圓角的散點圖項目 - 微軟表面SDK

我正在使用surfaceusercontrol在散點圖中添加表面項目。代碼如下:

<s:SurfaceUserControl x:Class="Models.ModelItemControl" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:s="http://schemas.microsoft.com/surface/2008" Width="110" Background="Transparent"> 

    <Grid> 
    <Grid.Background> 
     <ImageBrush ImageSource="pack://application:,,,/Resources/models_card_150-01.png" Opacity="1.0" Stretch="Fill" /> 
    </Grid.Background> 
    <Viewbox > 
    <StackPanel MaxWidth="250" MinHeight="300"> 
    <TextBlock Name="ItemTitle" Margin="5,5,5,5" TextWrapping="Wrap" Visibility="Visible" Padding="2" /> 
    <Image Name="ItemImage" Margin="5,5,5,5" Visibility="Visible" MaxHeight="100"/> 
    <TextBlock Name="ItemDesc" Margin="5,5,5,0" TextWrapping="Wrap" Visibility="Visible" Padding="2" /> 
    <s:SurfaceToggleButton Checked="ItemInfo_Checked" Unchecked="ItemInfo_Unchecked" Margin="5,0,5,0" HorizontalAlignment="Center" VerticalAlignment="Center">Display more info</s:SurfaceToggleButton> 
    </StackPanel> 
    </Viewbox> 
    </Grid> 
</s:SurfaceUserControl> 

我想要一個方法來將角落剪成圓形而不是矩形。

回答

1

可能你看到的是ScatterViewItems陰影,而不是你的UserControl。你可以使用下面的代碼去掉陰影:

item.ApplyTemplate(); 
item.Background = new SolidColorBrush(Colors.Transparent); 
item.ShowsActivationEffects = false; 
Microsoft.Surface.Presentation.Generic.SurfaceShadowChrome ssc; 
ssc = item.Template.FindName("shadow", item) as Microsoft.Surface.Presentation.Generic.SurfaceShadowChrome; 
ssc.Visibility = Visibility.Hidden; 

這個假定項目是你的ScatterViewItem。查看SDK中的ScatterViewPuzzle,瞭解如何爲ScatterViewItem製作自定義形狀。

+0

我想這個代碼中,我創建的每個scatterview項目和更換項目=這一點,但它沒有工作。在正常情況下在背景上看到的角落看起來很圓,但是當我將它移到另一個scatterview項目上時,顯示的邊框再次是矩形,節目也是矩形。通過使用你的代碼,我可以去除陰影,但是當重疊時角落仍然顯示出矩形形狀。 – 2010-11-11 15:19:09