Пример #1
0
        private async void SetMathView()
        {
            var vs = await GetMathSize();

            int  extra = 32;
            Size view  = ContentViewer.RenderSize;

            if (vs != Size.Empty)
            {
                if (MathView.ActualWidth != vs.Width + extra || vs.Width > view.Width - extra)
                {
                    MathView.Width = vs.Width + extra;
                    ContentViewer.HorizontalContentAlignment = HorizontalAlignment.Center;
                }
                else
                {
                    MathView.Width = view.Width - extra;
                }
                if (MathView.ActualHeight != vs.Height + extra || vs.Height > view.Height - extra)
                {
                    MathView.Height = vs.Height + extra;
                }
                else
                {
                    MathView.Height = view.Height - extra;
                }

                if (MathView.ActualWidth > ContentViewer.ActualWidth)
                {
                    ContentViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
                }
                else
                {
                    ContentViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                }

                if (MathView.ActualHeight > ContentViewer.ActualHeight)
                {
                    ContentViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
                }
                else
                {
                    ContentViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
                }

                //ContentViewer.UpdateLayout();
                ContentViewer.ChangeView((MathView.ActualWidth - ContentViewer.ActualWidth) / 2.0, 0, 1, true);
                //ContentViewer.VerticalScrollMode = ScrollMode.Auto;
            }
        }