通用的Windows应用程序SetTitleBar [英] Windows Universal App SetTitleBar

查看:624
本文介绍了通用的Windows应用程序SetTitleBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从微软的GitHub的存储库中的样本Title'Bar问题(的https:/ /github.com/JustinXinLiu/FullScreenTitleBarRepo/tree/master/FullScreenTitleBarRepo ):在AddCustomTitleBar功能,还有有一行:

  customTitleBar.EnableControlsInTitleBar(areControlsInTitleBar); 



EnableControlsInTitleBar是在这里:

 公共无效EnableControlsInTitleBar(BOOL启用)
{
如果(启用)
{
TitleBarControl.Visibility = Visibility.Visible;
//在BackgroundElement点击次数将被视为标题栏上点击。
Window.Current.SetTitleBar(BackgroundElement);
}
,否则
{
TitleBarControl.Visibility = Visibility.Collapsed;
Window.Current.SetTitleBar(NULL);
}
}



但如果我不叫建设中的作用(EnableControlsInTitleBar ),样品仍然运行良好。



在贾斯汀XL样品(的 https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/TitleBar )确实存在有使用本:

  Window.Current.SetTitleBar(BackgroundElement); 

这困扰了我,希望有人能给我解释一下,谢谢。


解决方案

但如果我不叫建设中的作用(EnableControlsInTitleBar),样品
依然工作得很好




我不认为这是事实。有几个地方会调用这个函数,所以我觉得你没有注释掉所有的人。



下面一行是用来让你自定义标题栏可以处理。输入(例如鼠标点击)喜欢默认的标题栏

  Window.Current.SetTitleBar(BackgroundElement); 



在这里取样品MS为例。如果我们没有任何变化启动MS样品,你可以做以下动作:



选择 2)自定义绘制 - >选择扩展视图到标题栏 - >勾选启用标题栏控制 - >您将看到下面的标题栏,并能够检查标题栏的复选框的



但是,如果我们注释掉SetTitleBar电话,该复选框不会响应你的鼠标点击。


I have a question about the Title'Bar sample from Microsoft's GitHub repository(https://github.com/JustinXinLiu/FullScreenTitleBarRepo/tree/master/FullScreenTitleBarRepo): In the AddCustomTitleBar function,there has a line:

customTitleBar.EnableControlsInTitleBar(areControlsInTitleBar); 

EnableControlsInTitleBar is here:

public void EnableControlsInTitleBar(bool enable)
{
    if (enable)
    {
        TitleBarControl.Visibility = Visibility.Visible;
        // Clicks on the BackgroundElement will be treated as clicks on the title bar.
        Window.Current.SetTitleBar(BackgroundElement);
    }
    else
    {
        TitleBarControl.Visibility = Visibility.Collapsed;
        Window.Current.SetTitleBar(null);
    }
}

but if I don't call the fuction(EnableControlsInTitleBar),the sample still work well

In Justin XL sample(https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/TitleBar) there indeed have use this:

Window.Current.SetTitleBar(BackgroundElement);

that puzzled me,hope somebody can give me a explain,thanks.

解决方案

"but if I don't call the fuction(EnableControlsInTitleBar),the sample still work well"

I don't think it's the truth. There are several places will call this function, so I think you didn't comment out all of them.

The following line is used to let your custom title bar can handle input(for example the mouse click) like default title bar.

Window.Current.SetTitleBar(BackgroundElement);

Take the MS sample as example here. If we launch the MS sample without any change, you can do the following actions:

Select "2) Custom drawing" -> check "Extend view into title bar" -> check "Enable controls in title bar" -> you will see the following title bar and be able to check the checkbox on title bar.

But if we comment out the SetTitleBar call, the checkbox will not response to your mouse click.

这篇关于通用的Windows应用程序SetTitleBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆