WPF inkcanvas背景图片调整大小

时间:2016-03-09 12:21:25

标签: c# wpf image inkcanvas

before i add label on ink canvas image look like this

  elhard = new Ellipse();
  elhard.Height = 5;
  elhard.Width = 5;
  elhard.Fill = Brushes.DarkOrange;
  InkCanvas.SetLeft(elhard, Mouse.GetPosition(inkcanvas).X);
  InkCanvas.SetTop(elhard, Mouse.GetPosition(inkcanvas).Y);
  inkcanvas.Children.Add(elhard);  

    lblhard = new System.Windows.Controls.Label();                 
    lblhard.FontSize = 25;
    lblhard.Content = hard_tisue[hardinc];   

                    lblhard.Foreground = new SolidColorBrush(System.Windows.Media.Colors.DarkMagenta);
                    InkCanvas.SetLeft(lblhard, Mouse.GetPosition(inkcanvas).X);
                    InkCanvas.SetTop(lblhard, Mouse.GetPosition(inkcanvas).Y);

                    inkcanvas.Children.Add(lblhard);

//这是我的xml      

                <InkCanvas x:Name="inkcanvas" ResizeEnabled="False"   EditingModeInverted="None"  Cursor="Pen" MouseMove="inkcanvas_MouseMove" MouseDown="inkcanvas_MouseDown" MouseRightButtonDown="inkcanvas_MouseRightButtonDown" MouseLeave="inkcanvas_MouseLeave" MoveEnabled="False"  UseLayoutRounding="False" ClipToBounds="False" ScrollViewer.HorizontalScrollBarVisibility="Visible" >
                    <InkCanvas.Background  >
                        <ImageBrush Stretch="None"  />
                    </InkCanvas.Background>



                </InkCanvas>

            <!--<Image Name="inkcanvas_image" Height="{Binding ActualHeight, ElementName=border}" Width="{Binding ActualWidth,ElementName=border}"  Stretch="Fill" Margin="1,1,1,1"  />-->

        </Border>

this is how background image in ink canvas moves to left side how to prevent image from moving

0 个答案:

没有答案