public static TextBlock CreateStickyLabel(FontSettings fontSettings, string text, double padding = 2.0)
        {
            var size = fontSettings.MeasureString(text);
            var tb   = new TextBlock();

            tb.Height = size.Height + 2 * padding;
            tb.Width  = size.Width + 2 * padding;
            tb.HorizontalAlignment = HorizontalAlignment.Center;
            tb.VerticalAlignment   = VerticalAlignment.Center;
            tb.Text = text;
            return(tb);
        }
示例#2
0
        public static TextBlock CreateStickyLabel(FontSettings fontSettings, string text, double padding = 2.0)
        {
            var size = fontSettings.MeasureString(text);
            // TODO (MICHA, 2020-10-04): check if font is set correctly ..
            // TODO (MICHA, 2020-10-04): seems, that for Textblock the alignement DOES NOT WORK!
            var tb = new TextBlock();

            tb.Height = size.Height + 2 * padding;
            tb.Width  = size.Width + 2 * padding;
            tb.HorizontalAlignment = HorizontalAlignment.Center;
            tb.VerticalAlignment   = VerticalAlignment.Center;
            tb.Text = text;
            return(tb);
        }