예제 #1
0
        private void UpdateCode()
        {
            var icon         = TextBoxHelper.GetIcon(TbCustom);
            var watermark    = TextBoxHelper.GetWatermark(TbCustom);
            var cornerRadius = SliderCornerRadius.Value;

            TbCode.Text = "<TextBox  Height=\"30\"" +
                          $"\nWidth=\"{TbCustom.Width}\"" +
                          (watermark == null ? "" : $"\npu:TextBoxHelper.Watermark=\"{watermark}\"") +
                          (icon == null ? "" : $"\npu:TextBoxHelper.Icon=\"{icon}\"") +
                          $"\npu:TextBoxHelper.FocusedBorderBrush=\"{TextBoxHelper.GetFocusedBorderBrush(TbCustom).ToColor().ToHexString(false)}\"" +
                          $"\npu:TextBoxHelper.FocusedShadowColor=\"{TextBoxHelper.GetFocusedShadowColor(TbCustom).ToHexString(false)}\"" +
                          (cornerRadius == 0 ? "" : $"\npu:TextBoxHelper.CornerRadius=\"{cornerRadius}\"") +
                          " />";
        }
예제 #2
0
        public static void ShowTruncatedTextAsToolTip(this TextBox textBox)
        {
            String wm = TextBoxHelper.GetWatermark(textBox);

            TextBoxHelper.SetWatermark(textBox, null);
            textBox.Measure(new Size(Double.MaxValue, Double.MaxValue));
            TextBoxHelper.SetWatermark(textBox, wm);
            var width = textBox.DesiredSize.Width;

            if (textBox.ActualWidth < width)
            {
                ToolTipService.SetToolTip(textBox, textBox.Text);
            }
            else
            {
                ToolTipService.SetToolTip(textBox, null);
            }
        }