我有一个Wpf listFiles()
控件。我无法找到任何可以使后退/前进导航箭头改变大小的属性,以便在平板电脑上更容易触摸。这样的事情存在吗?我是否可以使用样式而无需完全重新实现Frame
UI样式?
Frame
答案 0 :(得分:0)
这可以工作,尽管看上去并没有达到理想的抛光效果。
let fixArrowSize (frame:Frame) =
let adjustGridControl size (c:Control) =
c.MinHeight <- size
c.MinWidth <- size
c
|> Option.ofCast<Button>
|> Option.iter(fun b ->
let content = b.Content
let child = getTemplateChild b :?> Grid
child.MinHeight <- size
child.MinWidth <- size
)
match getDockPanel frame with
| null -> ()
| dp ->
let grid =
dp
|> getChildrenOfType<Grid>
|> Seq.head
grid
|> getChildrenOfType<System.Windows.Shapes.Path>
|> Seq.tryHead
|> Option.iter (fun path ->
grid.Children.Remove path
let size = 40.0
grid
|> getChildrenOfType<Control>
|> Seq.iter (adjustGridControl size)
)
()
static void FixArrowSize(Frame frame)
{
var dp = GetDockPanel(frame);
if (dp is null)
return;
var grid = dp.Children.OfType<Grid>().FirstOrDefault();
var path = grid.Children.OfType<System.Windows.Shapes.Path>().FirstOrDefault();
// we did it, we're going to be called multiple times, but only need to do our job once
if (path == null)
return;
grid.Children.Remove(path);
var size = 40.0;
grid.Children.OfType<Control>().ToList().ForEach(c =>
{
c.MinHeight = size;
c.MinWidth = size;
if (c is Button b)
{
var content = b.Content;
var child = GetTemplateChild(b) as Grid;
child.MinHeight = size;
child.MinWidth = size;
}
});
var cd = grid.ColumnDefinitions;
cd[0].Width = new GridLength(size);
cd[1].Width = new GridLength(size);
// no row definitions
var rd = grid.RowDefinitions;
grid.MinHeight = size;
}