2016-05-13 23 views
-2

我想在油墨畫布上書寫一些文字作爲筆畫集合,就像在ms paint上書寫文字一樣。 我正在使用Visual Studio 2015社區版。通過鍵盤在WPF油墨畫布上書寫文本

+1

請註明您已經嘗試什麼,以及如何你想要的東西? – stylishCoder

+0

如果你正在尋找WPF嘗試此鏈接http://stackoverflow.com/questions/16037753/wpf-drawing-on-canvas-with-mouse-events –

+0

我已經嘗試了inkcanvaseditingMode.Select,以及inkcanvaseditingMode.Erase以及用於繪製和擦除Stroks.now我想要在mscanint texttool這樣的inkcanvas上寫一些文本,並且這個鸛會通過Inkcanvitingitingmode.erase擦除。 –

回答

0

爲XAML代碼

<Grid > 
      <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 store sample" 

        Margin="10,0,0,0" /> 
      <Button x:Name="btnSave" 
       Content="Save" 
       Margin="50,0,10,0"> 
       <Button.InputBindings> 

        <MouseBinding MouseAction="LeftDoubleClick" Gesture="LeftClick" 
          Command="{Binding Path=MouseClickCommand}" 
          CommandParameter="{Binding ElementName=myGrd, Path=SelectedItem}"/> 
       </Button.InputBindings> 

      </Button> 
       <Button x:Name="btnLoad" 
       Content="Load" 
       Margin="50,0,10,0"/> 
       <Button x:Name="btnClear" 
       Content="Clear" 
       Margin="50,0,10,0"/> 
      </StackPanel> 
      <Grid Grid.Row="1"> 
       <InkCanvas x:Name="inkCanvas" /> 
      </Grid> 
     </Grid> 

查看型號代碼

#region Fire Mouse Click 
     private RelayCommand<object> _cmdMouseEnterCommand; 
     public ICommand MouseClickCommand 
     { 
      get { return _cmdMouseEnterCommand ?? (_cmdMouseEnterCommand = new RelayCommand<object>(mExecute)); } 
     } 
     private bool CanExecuteMouseEnterCommand() 
     { 
      return true; 
     } 
     public void mExecute(object sender) 
     { 
      Signature = (System.Windows.Ink.StrokeCollection)sender; 

     } 
     #endregion 
+1

如何實現這個僞..你會plz精心製作。 –

+0

我不明白...你要我解釋在哪裏寫的代碼片? – stylishCoder

+0

yess,我想在inkcanvas上寫一些文字作爲按鈕clik ..事件中的stroks。後來我可以使用inkcanvaseditingmode.Erase事件來清除這些問題。如此輕鬆地告訴我,我把你的僞裝。對於壞語法感到抱歉。 –

相關問題