Share via


InkToolbar.InitialControls Propriedade

Definição

Obtém ou define a coleção de botões internos adicionados ao InkToolbar na inicialização.

Essa propriedade substitui a coleção padrão de botões internos.

Por padrão, o InkToolbar consiste em dois grupos distintos de tipos de botão:

A seleção de recursos é mutuamente excludente.

Os recursos não são mutuamente excludentes e podem ser usados concomitantemente com outras ferramentas ativas.

public:
 property InkToolbarInitialControls InitialControls { InkToolbarInitialControls get(); void set(InkToolbarInitialControls value); };
InkToolbarInitialControls InitialControls();

void InitialControls(InkToolbarInitialControls value);
public InkToolbarInitialControls InitialControls { get; set; }
var inkToolbarInitialControls = inkToolbar.initialControls;
inkToolbar.initialControls = inkToolbarInitialControls;
Public Property InitialControls As InkToolbarInitialControls

Valor da propriedade

A coleção de botões internos a serem adicionados ao InkToolbar.

Exemplos

Para especificar quais botões internos são exibidos na inicialização:

  1. Defina InitialControls como Nenhum.
  2. Adicione os botões individuais.
  3. Especifique a experiência de interface do usuário do InkToolbar , como o botão padrão. Os exemplos a seguir (XAML e code-behind) mostram como limpar os botões padrão do InkToolber, adicionar caneta esferográfica, lápis e botões de borracha e definir o botão padrão como lápis.

XAML

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <StackPanel x:Name="HeaderPanel" Orientation="Horizontal" Grid.Row="0">
        <TextBlock x:Name="Header" 
                   Text="Basic ink sample" 
                   Style="{ThemeResource HeaderTextBlockStyle}" 
                   Margin="10,0,0,0" />
    </StackPanel>
    <Grid Grid.Row="1">
        <Image Source="Assets\StoreLogo.png" />
        <!-- Clear the default InkToolbar buttons by setting InitialControls to None. -->
        <!-- Set the active tool to the pencil button. -->
        <InkCanvas x:Name="inkCanvas" />
        <InkToolbar x:Name="inkToolbar" 
                    VerticalAlignment="Top" 
                    TargetInkCanvas="{x:Bind inkCanvas}" 
                    InitialControls="None"
                    ActiveTool="{x:Bind pencilButton}">
            <!-- 
             Add only the ballpoint pen, pencil, and eraser. 
             Note that the buttons are added to the toolbar in the order 
             defined by the framework, not the order we specify here.
            -->
            <InkToolbarEraserButton />
            <InkToolbarBallpointPenButton />
            <InkToolbarPencilButton x:Name="pencilButton"/>
        </InkToolbar>
    </Grid>
</Grid>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <StackPanel x:Name="HeaderPanel" Orientation="Horizontal" Grid.Row="0">
        <TextBlock x:Name="Header" 
                   Text="Basic ink sample" 
                   Style="{ThemeResource HeaderTextBlockStyle}" 
                   Margin="10,0,0,0" />
    </StackPanel>
    <Grid Grid.Row="1">
        <Image Source="Assets\StoreLogo.png" />
        <InkCanvas x:Name="inkCanvas" />
        <InkToolbar x:Name="inkToolbar" VerticalAlignment="Top" TargetInkCanvas="{x:Bind inkCanvas}" />
    </Grid>
</Grid>
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// Here, we set up InkToolbar event listeners.
/// </summary>
public MainPage_CodeBehind()
{
    this.InitializeComponent();
    // Add handlers for InkToolbar events.
    inkToolbar.Loading += inkToolbar_Loading;
    //inkToolbar.Loaded += inkToolbar_Loaded;
}
/// <summary>
/// Handles the Loading event of the InkToolbar. 
/// Here, we identify the buttons to include on the InkToolbar.
/// </summary>
/// <param name="sender">The InkToolbar</param>
/// <param name="args">The InkToolbar event data. 
/// If there is no event data, this parameter is null</param>
private void inkToolbar_Loading(FrameworkElement sender, object args)
{
    // Clear all built-in buttons from the InkToolbar.
    inkToolbar.InitialControls = InkToolbarInitialControls.None;

    // Add only the ballpoint pen, pencil, and eraser.
    // Note that the buttons are added to the toolbar in the order
    // defined by the framework, not the order we specify here.
    InkToolbarBallpointPenButton ballpoint = new InkToolbarBallpointPenButton();
    InkToolbarPencilButton pencil = new InkToolbarPencilButton();
    InkToolbarEraserButton eraser = new InkToolbarEraserButton();
    inkToolbar.Children.Add(eraser);
    inkToolbar.Children.Add(ballpoint);
    inkToolbar.Children.Add(pencil);
}
/// <summary>
/// Handle the Loaded event of the InkToolbar.
/// By default, the active tool is set to the first tool on the toolbar.
/// Here, we set the active tool to the pencil button. 
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void inkToolbar_Loaded(object sender, RoutedEventArgs e)
{
    InkToolbarToolButton pencilButton = inkToolbar.GetToolButton(InkToolbarTool.Pencil);
    inkToolbar.ActiveTool = pencilButton;
}

Comentários

Os botões internos padrão, ou aqueles especificados por meio de InitialControls, não são adicionados à propriedade Children .

Botões internos ou personalizados adicionados programaticamente ou declarados em XAML são adicionados à propriedade Children .

Os botões internos são exibidos em uma ordem predeterminada em seus respectivos grupos de controle. Os botões personalizados são adicionados ao grupo de controle apropriado na ordem especificada, após todos os botões internos.

Aplica-se a

Confira também