none
怎样自定义FlowDocumentReader控件的页面导航及视图切换按钮?仅仅放大也行(原因:触摸屏环境) RRS feed

  • 问题

  •  

    用FlowDocumentReader显示FlowDocument是很爽。自动给你分页等等。不过有个问题是在触摸屏环境下那个页面切换按钮也未免太小了。点好几次才能点上。

     

     

    2008年12月1日 1:37

答案

  •  

    你可以试一下用Template来重新定义FlowDocumentReader的外观,一个比较简单的办法就是把WPFFlowDocumentReader的模板Dump下来,然后稍微改一改,重新设置FlowDocumentReader的Template,下面的代码可以帮助你Dump一个控件的Template:

     

    代码是从Applications = Code + Markup: A Guide to the Microsoft® Windows® Presentation Foundation里面拷贝的

     

    void DumpTemplateOnClick(object sender, RoutedEventArgs args)
            {
                if (ctrl != null)
                    Dump(ctrl.Template);
            }


            // Dump ItemsPanelTemplate object attached to ItemsPanel property.
            void DumpItemsPanelOnClick(object sender, RoutedEventArgs args)
            {
                if (ctrl != null && ctrl is ItemsControl)
                    Dump((ctrl as ItemsControl.ItemsPanel);
            }

      void Dump(FrameworkTemplate template)
            {
                if (template != null)
                {
                    // Dump the XAML into the TextBox.
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;
                    settings.IndentChars = new string(' ', 4);
               settings.NewLineOnAttributes = true;

                    StringBuilder strbuild = new StringBuilder();
               XmlWriter xmlwrite = XmlWriter.Create(strbuild, settings);

                    try
                    {
                        XamlWriter.Save(template, xmlwrite);
                   txtbox.Text = strbuild.ToString();
                    }
                    catch (Exception exc)
                    {
                        txtbox.Text = exc.Message;
                    }
                }
                else
                    txtbox.Text = "no template";
            }

    2008年12月5日 11:19