【发布时间】:2015-10-21 11:05:04
【问题描述】:
我在Flyout 中有一个ListBox。有什么方法可以让我的ListBox 圆角?我已经搜索过,我找不到任何东西。有没有你推荐的 style/Xaml 模板?
这是我的代码:
<Flyout>
<Flyout.FlyoutPresenterStyle>
<Style TargetType="FlyoutPresenter">
<Setter Property="Margin" Value="30,30,0,0"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="MinHeight" Value="300"/>
<Setter Property="MinWidth" Value="200"/>
</Style>
</Flyout.FlyoutPresenterStyle>
<ListBox x:Name="AllItemsView" Width="200" Height="auto" BorderThickness="0" VerticalAlignment="Top" Foreground="Black" Background="White" Grid.RowSpan="2" ItemsSource="{Binding}" SelectionMode="Single" SelectionChanged="AllItemsView_SelectionChanged">
<ListBox.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="20,20,20,20"/>
<Setter Property="BorderBrush" Value="BlueViolet"/>
<Setter Property="BorderThickness" Value="7"/>
<Setter Property="Padding" Value="5"/>
</Style>
</ListBox.Resources>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderThickness" Value="1"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Width="200" Height="40" Margin="0,0,0,0" Name="colorGrid">
<Grid.Background>
<SolidColorBrush Color="{Binding ItemType, Mode=OneWay, Converter={StaticResource ItemTypeToColorConverter1}}" />
</Grid.Background>
<StackPanel x:Name="StackItem">
<TextBlock Text="{Binding ItemTitle}" FontWeight="{Binding ItemType, Converter={StaticResource itemTypeToBoldConverter1}}" Margin="{Binding ItemType, Converter={StaticResource itemTypeToMarginConverter1}}" />
<TextBlock Text="{Binding ItemPage}" Visibility="Collapsed"/>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Flyout>
【问题讨论】:
标签: c# xaml listbox windows-store-apps styles