The C1RadialColorItem class allows you to create a color picker using the C1RadialMenu control. In this topic, you'll create a C1RadialMenu application and add C1RadialColorItems to the C1RadialMenu control. You'll use both XAML markup and code to create the application.
Complete the following steps to create a color picker radial menu:
XAML |
Copy Code
|
---|---|
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Border Background="LemonChiffon" MinHeight="40" BorderBrush="#969696" BorderThickness="1" Padding="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <c1:C1ContextMenuService.ContextMenu> </c1:C1ContextMenuService.ContextMenu> <c1:C1ListViewer x:Name="text" Foreground="Sienna" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="75" ZoomMode="Disabled"> <TextBlock Text="Touch: hold down for a few seconds until the indicator displays. Keyboard: press the context-menu button over this text. Mouse: right-click over this text." FontSize="16" TextWrapping="Wrap" /> </c1:C1ListViewer> </Border> <TextBlock x:Name="txt" Foreground="Red" Text="" FontSize="16" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="10" /> </Grid> |
XAML |
Copy Code
|
---|---|
<c1:C1RadialMenu x:Name="contextMenu" Offset="-130,0" ItemClick="contextMenu_ItemClick" > |
XAML |
Copy Code
|
---|---|
<c1:C1RadialColorItem x:Name="rainbowItem" ShowSelectedItem="True" AutoSelect="True" IsSelectable="False" > </c1:C1RadialColorItem> <c1:C1RadialColorItem x:Name="greenItem" SelectedIndex="5" ShowSelectedItem="True" AutoSelect="True" IsSelectable="False" > </c1:C1RadialColorItem> <c1:C1RadialColorItem x:Name="blueItem" SelectedIndex="0" ShowSelectedItem="True" AutoSelect="True" IsSelectable="False" > </c1:C1RadialColorItem> |
XAML |
Copy Code
|
---|---|
<SolidColorBrush Color="Red"/> <SolidColorBrush Color="Orange"/> <SolidColorBrush Color="Yellow"/> <SolidColorBrush Color="Green"/> <SolidColorBrush Color="Blue"/> <SolidColorBrush Color="Indigo"/> <SolidColorBrush Color="Violet"/> |
XAML |
Copy Code
|
---|---|
<c1:C1RadialColorItem x:Name="greenItem" SelectedIndex="5" ShowSelectedItem="True" AutoSelect="True" IsSelectable="False"> <c1:C1RadialColorItem ToolTip="Lime" Brush="#FF92D050" GroupName="Green"/> <c1:C1RadialColorItem ToolTip="Light Green" Brush="#FFC6EFCE" GroupName="Green"/> <c1:C1RadialColorItem ToolTip="Green" Brush="#FF00FF00" GroupName="Green"/> <c1:C1RadialColorItem ToolTip="Dark Green" Brush="#FF1D421E" GroupName="Green"/> <c1:C1RadialColorItem ToolTip="Dark Green" Brush="#FF1D5A2D" GroupName="Green"/> <c1:C1RadialColorItem ToolTip="Dark Green" Brush="Green" GroupName="Green"/> <c1:C1RadialColorItem ToolTip="Dark Green" Brush="#FF008000" GroupName="Green"/> <c1:C1RadialColorItem ToolTip="Dark Green" Brush="#FF00B050" GroupName="Green"/> </c1:C1RadialColorItem> |
XAML |
Copy Code
|
---|---|
<c1:C1RadialColorItem x:Name="blueItem" SelectedIndex="0" ShowSelectedItem="True" AutoSelect="True" IsSelectable="False" > <c1:C1RadialColorItem ToolTip="Blue" Brush="Blue" GroupName="Blue"/> <c1:C1RadialColorItem ToolTip="Slate Blue" Brush="MediumSlateBlue" GroupName="Blue"/> <c1:C1RadialColorItem ToolTip="Turquoise" Brush="Turquoise" GroupName="Blue"/> <c1:C1RadialColorItem ToolTip="Aqua" Brush="Aqua" GroupName="Blue"/> <c1:C1RadialColorItem ToolTip="Sky Blue" Brush="SkyBlue" GroupName="Blue"/> <c1:C1RadialColorItem ToolTip="Purple" Brush="#FFAC38AC" AccentBrush="#FF801C80" GroupName="Blue"/> <c1:C1RadialColorItem ToolTip="Dark Purple" Brush="Purple" GroupName="Blue"/> <c1:C1RadialColorItem ToolTip="Dark Blue" Brush="DarkBlue" GroupName="Blue"/> </c1:C1RadialColorItem> |
C# |
Copy Code
|
---|---|
using C1.WPF.Core; using C1.WPF.Menu; |
C# |
Copy Code
|
---|---|
private void contextMenu_ItemClick(object sender, SourcedEventArgs e) { C1RadialMenuItem item = e.Source as C1RadialMenuItem; if (item is C1RadialColorItem) { this.text.Foreground = ((C1RadialColorItem)item).Brush; txt.Text = "Item Clicked: " + ((C1RadialColorItem)item).Color.ToString(); } else { txt.Text = "Item Clicked: " + (item.Header ?? item.Name).ToString(); } } |