我的UWP应用程序有两个inkToolbars。如图所示,水平的是完全定制的。它有一些inkToolbarCustomToolButtons,如“NewInk”,“SaveInk”,“Settngs”等。
垂直是一半定制。它有一些原始的inkToolbarToolButtons和一些自定义按钮。
现在,如果我只使用垂直inkToolbar,则fisrt inkToolbarBallpointPenButton处于活动状态,我可以在我的应用程序上绘制。
<InkToolbar x:Name="inkToolbar1" x:FieldModifier="Public" Grid.Column="0" Grid.RowSpan ="2" Grid.ColumnSpan="2" InitialControls="None" TargetInkCanvas="{x:Bind inkCanvas}" HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal">
<InkToolbarCustomToolButton x:Name="toggleButtonNewInk" Click="toggleButtonNewInk_Click">
<SymbolIcon Symbol="Page2">
<ToolTipService.ToolTip>
<ToolTip x:Uid="ToolTipNewInk" Content="NewInk"/>
</ToolTipService.ToolTip>
</SymbolIcon>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="toggleButtonClearAllInk" Click="toggleButtonClearAllInk_Click">
<SymbolIcon Symbol="Document">
<ToolTipService.ToolTip>
<ToolTip x:Uid="ToolTipClearAllInk" Content="ClearAllInk"/>
</ToolTipService.ToolTip>
</SymbolIcon>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="toggleButtonLoadInk" Click="toggleButtonLoadInk_Click">
<SymbolIcon Symbol="OpenFile">
<ToolTipService.ToolTip>
<ToolTip x:Uid="ToolTipLoadInk" Content="LoadInk"/>
</ToolTipService.ToolTip>
</SymbolIcon>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="toggleButtonSaveInk" Click="toggleButtonSaveInk_Click">
<SymbolIcon Symbol="Save">
<ToolTipService.ToolTip>
<ToolTip x:Uid="ToolTipSaveInk" Content="SaveInk"/>
</ToolTipService.ToolTip>
</SymbolIcon>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="toggleButtonSavePictures" Click="toggleButtonSavePictures_Click">
<SymbolIcon Symbol="Pictures">
<ToolTipService.ToolTip>
<ToolTip x:Uid="ToolTipSavePictures" Content="SavePictures"/>
</ToolTipService.ToolTip>
</SymbolIcon>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="toggleButtonBackground" Click="toggleButtonBackground_Click">
<SymbolIcon Symbol="BrowsePhotos">
<ToolTipService.ToolTip>
<ToolTip x:Uid="ToolTipBackground" Content="SelectBackground"/>
</ToolTipService.ToolTip>
</SymbolIcon>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="toggleButtonBackgroundOpacity" Click="toggleButtonBackgroundOpacity_Click">
<SymbolIcon Symbol="HideBcc">
<ToolTipService.ToolTip>
<ToolTip x:Uid="ToolTipBackgroundOpacity" Content="BackgroundOpacity"/>
</ToolTipService.ToolTip>
</SymbolIcon>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="toggleButtonCopy" Click="toggleButton_Copy">
<SymbolIcon Symbol="{x:Bind Copy}">
<ToolTipService.ToolTip>
<ToolTip x:Uid="ToolTipCopy" Content="Copy"/>
</ToolTipService.ToolTip>
</SymbolIcon>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="toggleButtonCut" Click="toggleButton_Cut">
<SymbolIcon Symbol="{x:Bind Cut}">
<ToolTipService.ToolTip>
<ToolTip x:Uid="ToolTipCut" Content="Cut"/>
</ToolTipService.ToolTip>
</SymbolIcon>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="toggleButtonPaste" Click="toggleButton_Paste">
<SymbolIcon Symbol="{x:Bind Paste}">
<ToolTipService.ToolTip>
<ToolTip x:Uid="ToolTipPaste" Content="Paste"/>
</ToolTipService.ToolTip>
</SymbolIcon>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="undoButton" Click="Undo_Click">
<SymbolIcon Symbol="Undo">
<ToolTipService.ToolTip>
<ToolTip x:Uid="ToolTipUndo" Content="Undo"/>
</ToolTipService.ToolTip>
</SymbolIcon>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="redoButton" Click="Redo_Click">
<SymbolIcon Symbol="Redo">
<ToolTipService.ToolTip>
<ToolTip x:Uid="ToolTipRedo" Content="Redo"/>
</ToolTipService.ToolTip>
</SymbolIcon>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="toggleButtonReplay" Click="toggleButtonReplay_Click">
<SymbolIcon Symbol="Slideshow">
<ToolTipService.ToolTip>
<ToolTip x:Uid="ToolTipReplay" Content="Replay"/>
</ToolTipService.ToolTip>
</SymbolIcon>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="toggleButtonReset" Click="toggleButtonReset_Click">
<SymbolIcon Symbol="Rotate">
<ToolTipService.ToolTip>
<ToolTip x:Uid="ToolTipStopReplay" Content="StopReplay"/>
</ToolTipService.ToolTip>
</SymbolIcon>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="toggleButtonSettings" Click="toggleButtonSettings_Click">
<SymbolIcon Symbol="Setting">
<ToolTipService.ToolTip>
<ToolTip x:Uid="ToolTipSettings" Content="Settings"/>
</ToolTipService.ToolTip>
</SymbolIcon>
</InkToolbarCustomToolButton>
</InkToolbar>
<InkToolbar x:Name="inkToolbar2" x:FieldModifier="Public" Grid.Row="1" Grid.RowSpan="2" Grid.ColumnSpan="2" TargetInkCanvas="{x:Bind inkCanvas}" HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Vertical">
<InkToolbar.Resources>
<BrushCollection x:Key="CalligraphicPenPalette">
<SolidColorBrush>Black</SolidColorBrush>
<SolidColorBrush>White</SolidColorBrush>
<SolidColorBrush Color="#FFD1D3D4"/>
<SolidColorBrush Color="#FFA7A9AC"/>
<SolidColorBrush Color="#FF808285"/>
<SolidColorBrush Color="#FF58595B"/>
<SolidColorBrush Color="#FFB31564"/>
<SolidColorBrush Color="Red"/>
<SolidColorBrush Color="#FFFF5500"/>
<SolidColorBrush Color="#FFFFAA00"/>
<SolidColorBrush Color="#FFFFCE00"/>
<SolidColorBrush Color="#FFFFE600"/>
<SolidColorBrush Color="#FFA2E61B"/>
<SolidColorBrush Color="#FF26E600"/>
<SolidColorBrush Color="#FF008055"/>
<SolidColorBrush Color="#FF00AACC"/>
<SolidColorBrush Color="#FF004DE6"/>
<SolidColorBrush Color="#FF3D00B8"/>
<SolidColorBrush Color="#FF6600CC"/>
<SolidColorBrush Color="#FF600080"/>
<SolidColorBrush Color="#FFF7D7C4"/>
<SolidColorBrush Color="#FFBB9167"/>
<SolidColorBrush Color="#FF8E562E"/>
<SolidColorBrush Color="#FF613D30"/>
<SolidColorBrush Color="#FFFF80FF"/>
<SolidColorBrush Color="#FFFFC680"/>
<SolidColorBrush Color="#FFFFFF80"/>
<SolidColorBrush Color="#FF80FF9E"/>
<SolidColorBrush Color="#FF80D6FF"/>
<SolidColorBrush Color="#FFBCB3FF"/>
</BrushCollection>
<local:CalligraphicPen x:Key="CalligraphicPen"/>
</InkToolbar.Resources>
<InkToolbarCustomPenButton x:Name="calligraphyPen"
CustomPen="{StaticResource CalligraphicPen}"
Palette="{StaticResource CalligraphicPenPalette}"
SelectedBrushIndex="0"
MinStrokeWidth="4"
MaxStrokeWidth="10"
ToolTipService.ToolTip="CalligraphyPen">
<InkToolbarCustomPenButton.ConfigurationContent>
<InkToolbarPenConfigurationControl/>
</InkToolbarCustomPenButton.ConfigurationContent>
<Border>
<Grid>
<TextBlock AutomationProperties.AccessibilityView="Raw" FontFamily="Segoe MDL2 Assets" Text="" Canvas.ZIndex="1"/>
<TextBlock AutomationProperties.AccessibilityView="Raw" FontFamily="Segoe MDL2 Assets" Text=""
Foreground="{x:Bind calligraphyPen.SelectedBrush, Mode=OneWay}" Canvas.ZIndex="0"/>
</Grid>
</Border>
</InkToolbarCustomPenButton>
<InkToolbarCustomToolButton x:Name="toolButtonColorPicker" Click="ToolButton_ColorPicker" ToolTipService.ToolTip="ColorPicker">
<Image Height="20" Width="20" Source="ms-appx:///Assets/Palette.png"/>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="toolButtonLasso" Click="ToolButton_Lasso" ToolTipService.ToolTip="Selection tool">
<SymbolIcon Symbol="{x:Bind LassoSelect}"/>
</InkToolbarCustomToolButton>
<InkToolbarCustomToggleButton x:Name="toggleTouch" Click="Toggle_Touch" ToolTipService.ToolTip="Touch Writing">
<SymbolIcon Symbol="{x:Bind TouchWriting}"/>
</InkToolbarCustomToggleButton>
<InkToolbarCustomToggleButton x:Name="toggleMouse" Click="Toggle_Mouse" ToolTipService.ToolTip="Mouse Writing">
<Grid>
<Grid x:Name="backgroundGrid" Width="48" Height="48" Visibility="Collapsed" />
<Path Data="M9.9999777,8.0546999L9.9999777,15.988959 7.9999777,15.988959 7.9999777,8.0547061 7.9353534,8.063777C4.5788473,8.5782027,1.9999997,11.485739,1.9999995,14.982962L1.9999995,15.988976 15.99999,15.988976 15.99999,17.988976 1.9999995,17.988976 1.9999995,22.999972C1.9999997,26.858977 5.1399997,29.999981 8.9999996,29.999981 12.859999,29.999981 16,26.858977 16,22.999972L16,14.982962C16,11.485739,13.421152,8.5782027,10.064646,8.063777z M8.9999996,7.982954L8.996245,7.9830017 9.0037543,7.9830017z M17.968911,0C17.970911,0.24400043 17.95291,2.4140015 16.674872,3.5620012 16.082855,4.0940018 15.322832,4.3240013 14.466807,4.2230015 13.449776,4.1050014 12.680753,3.6420012 12.061735,3.2710018 11.263712,2.7910013 10.8857,2.5880013 10.280682,2.828001 9.5819117,3.1010017 9.605373,4.7114782 9.805019,5.9119158L9.8240258,6.021059 9.9187862,6.0295C14.450976,6.4911938,18,10.330144,18,14.982962L18,22.999972C18,27.961978 13.962,31.999984 8.9999996,31.999984 4.0379997,31.999984 -2.3841858E-07,27.961978 0,22.999972L0,14.982962C-2.3841858E-07,10.485238,3.316365,6.7480278,7.6313664,6.086832L7.8013331,6.0629797 7.7834183,5.9472485C7.5516907,4.3561869 7.5199753,1.7596569 9.5526606,0.9640007 11.098707,0.36000061 12.20374,1.0230007 13.091766,1.5560007 13.615781,1.8710012 14.109796,2.1680012 14.698814,2.2370014 15.058824,2.2770014 15.228829,2.1730013 15.336833,2.0760012 15.817847,1.6470013 15.970852,0.50200081 15.968852,0.015000343z" Stretch="Uniform" Fill="#FFFFFDFD" Width="24" Height="24" Margin="0,0,0,0" RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<TransformGroup>
<RotateTransform Angle="0" />
<ScaleTransform ScaleX="1" ScaleY="1" />
</TransformGroup>
</Path.RenderTransform>
</Path>
</Grid>
</InkToolbarCustomToggleButton>
<InkToolbarCustomToolButton x:Name="toggleButtonZoomIn" Click="toggleButtonZoomIn_Click">
<SymbolIcon Symbol="ZoomIn" ToolTipService.ToolTip="ZoomIn"/>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="toggleButtonZoomOut" Click="toggleButtonZoomOut_Click">
<SymbolIcon Symbol="ZoomOut" ToolTipService.ToolTip="ZoomOut"/>
</InkToolbarCustomToolButton>
<InkToolbarCustomToolButton x:Name="toggleButtonFullExtent" Click="toggleButtonFullExtent_Click">
<SymbolIcon Symbol="Zoom" ToolTipService.ToolTip="FullExtent"/>
</InkToolbarCustomToolButton>
</InkToolbar>
但是!!!当我加载两个inkToolbars时,inkToolbarBallpointPenButton因某些未知原因而处于非活动状态。我必须先单击其他按钮,然后单击inkToolbarBallpointPenButton,它才会以这种方式变为活动状态。
有谁知道为什么?感谢。
答案 0 :(得分:1)
我找到了!!! 在inkToolbar1中,我设置了I TargetInkCanvas =&#34; {x:Bind inkCanvas}&#34;。
删除TargetInkCanvas !!!