-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Dialog/Drawer/MessageBox option: StyleClass #465
Conversation
2. Provide sample for Dialog StyleClass option.
@dameng324 @genment please help to review. |
代码本身我看不出有什么问题,但我不太喜欢这样的设计。
个人看法,仅供参考。 |
那我已经迷茫了,这个API应该设计成什么样子? |
我觉得有 更复杂的可以考虑将这些东西放到一个ViewModel中(如Title/Icon/Button内容),用户可以传递这个viewmodel实例进去,Ursa将这个ViewModel实例绑定到View中。 仅供参考。 |
基本不太可行,因为从此我会陷入和社区无尽的争吵:“为什么Content可以作为options而XX不能作为options呢?” |
我也觉得这个使用方法有点复杂。在不更改现有Dialog/Drawer/MessageBox的前提下,增加新的控件的可行性如何?参考 FluentAvalonia 的做法? |
The PR itself solves many issues, although not satisfying #422 . Will leave that open, and merge this one. |
This is the feature requested by multiple community users, such as #422
这是一个社区用户一直想要的功能,详见 #422
In general, we don't want to add a huge number of options for user to customize each button's content, order, foreground, background etc. For me this is a bad design in traditional XAML framework because they cannot touch the elements inside template easily. In Avalonia we do have the ability to customize template elements, so this new option can help you to apply a predefined style for Default
Dialog
andMessageBox
.Ursa整体上不希望将Dialog option 设计得过于复杂,例如为每个按钮的文字、位置、颜色等增加配置项。对于我来说,这是其他XAML框架的设计问题,因为在WPF等框架中不能方便地访问控件模板内的内容,他们别无选择。在Avalonia中我们有更改控件模板元素的能力,因此我们只需要为Dialog传入一个Class,即可将定义好的样式应用在上面。
How to use
使用方法
Example 例如:
Custom
as theStyleClass
when you invoke a Dialog. 在调用Dialog的时候将Custom
作为StyleClass
参数The new created Dialog will have this Style applied. 新创建的Dialog就会应用此样式
Where to define the Style?
样式应该在哪里定义
To help you set Style class for template elements inside a style, We exposed a ClassHelper.Classes as attached property. You should limit this usage, and keep it static. It is your responsibility to avoid loop style activation.
为了方便用户在Style中为模板元素应用样式类,我们暴露了ClassHelper.Classes作为依赖属性。你应该谨慎使用这一功能,并确保设计的样式不会出现循环触发问题。
Breaking Changes
破坏性更新
This pull request introduced a binary breaking change (no code breaking change). that
IDialogContext
interface is moved to another assembly. Developer needs to re-compile your application to include this dependency.这个PR引入了一个破坏性更新,
IDialogContext
移入了另一个assembly。开发者升级后需要重新编译项目(无需修改代码)。