Hi, im programming with c#, and im doing one form using WPF, and i need show texts on it. Im using code below to draw text, but font size appears smaller than size indicated (i defined as arial 160, and appears about 118). I dont know what im doing bad, somebody can help me please. Also, over text appears a space, i want that text starts at heigh indicated in texbox position not below; you can see small line as texbox container.
thanks a lot.
- TextBox textBox = new TextBox();
- textBox.BorderThickness = new Thickness(1);
- textBox.IsHitTestVisible = false;
- textBox.Focusable = false;
- textBox.TextWrapping = TextWrapping.WrapWithOverflow;
- textBox.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
- textBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
- textBox.Tag = (object)mText.Id;
- textBox.Text = mText.Text;
- textBox.FontSize = mText.Size;
- textBox.Foreground = XDisplay.ConvertStringColorToBrush(mText.Color);
- textBox.Background = XDisplay.ConvertStringColorToBrush(mText.BackgroundColor);
- textBox.FontFamily = new FontFamily(mText.FontName);
- textBox.FontWeight = mText.Bold ? FontWeights.Bold : FontWeights.Normal;
- textBox.FontStyle = mText.Italic ? FontStyles.Italic : FontStyles.Normal;
- textBox.Opacity = mText.Opacity;
- textBox.Width = mText.Width;
- textBox.Height = mText.Height;
- textBox.TextAlignment = (TextAlignment)mText.Alignment;
- Canvas.SetTop(textBox, mText.Y);
- Canvas.SetLeft(textBox, mText.X);
- Panel.SetZIndex(textBox, mText.Layer);
- return textBox;