Prism.Avalonia
Prism.Avalonia copied to clipboard
[Enhancement] Add dialog style Settings
Description
Dialog style Settings are currently invalid, whether to add this feature, in the wpf version of prism is supported to set dialog style, this feature is still important
Context
<prism:Dialog.WindowStyle>
<style selector="Window">
<Setter Property="Background" Value="Red"/>
</style>
</prism:Dialog.WindowStyle>
需要使用 DialogWindow 来去修改 对话框窗口的样式
需要新建一个 window 实现IDialogWindow接口,像这样
public partial class TestDialogWindow : Window, IDialogWindow
{
public TestDialogWindow()
{
InitializeComponent();
}
public IDialogResult? Result { get; set; }
object? IDialogWindow.Content { get => null; set { if (value != null) Dock.Children[1] = (Control)value; } }
}
xaml
<Window.Styles>
<Style Selector="Window">
<Setter Property="SizeToContent" Value="WidthAndHeight" />
</Style>
</Window.Styles>
<Border Padding="2 2 2 2">
<DockPanel MinWidth="200" x:Name="Dock" LastChildFill="True">
<Border DockPanel.Dock="Top" Height="40">
<Label Content="{Binding Title}" VerticalAlignment="Center" HorizontalContentAlignment="Left" />
</Border>
<Border />
</DockPanel>
</Border>
然后注册DialogWindow 和 Dialog
containerRegistry.RegisterDialog<LoadingBox, LoadingBoxViewModel>(nameof(LoadingBox));
containerRegistry.RegisterDialogWindow<TestDialogWindow>("test");
使用的时候 需要这样使用
_dialogService.ShowDialog(nameof(LoadingBox), param, r =>{},"test");
这样dialog的窗口样式就改变成你修改的样式了
需要使用 DialogWindow 来去修改 对话框窗口的样式
需要新建一个 window 实现IDialogWindow接口,像这样 `public partial class TestDialogWindow : Window, IDialogWindow { public TestDialogWindow() { InitializeComponent(); }
public IDialogResult? Result { get; set; } object? IDialogWindow.Content { get => null; set { if (value != null) Dock.Children[1] = (Control)value; } } }`
xaml:
<Window.Styles> <Style Selector="Window"> <Setter Property="SizeToContent" Value="WidthAndHeight" /> </Style> </Window.Styles> <Border Padding="2 2 2 2"> <DockPanel MinWidth="200" x:Name="Dock" LastChildFill="True"> <Border DockPanel.Dock="Top" Height="40"> <Label Content="{Binding Title}" VerticalAlignment="Center" HorizontalContentAlignment="Left" /> </Border> <Border /> </DockPanel> </Border>
然后注册DialogWindow 和 Dialog
containerRegistry.RegisterDialog<LoadingBox, LoadingBoxViewModel>(nameof(LoadingBox)); containerRegistry.RegisterDialogWindow<TestDialogWindow>("test");
使用的时候 需要这样使用_dialogService.ShowDialog(nameof(LoadingBox), param, r =>{},"test");
这样dialog的窗口样式就改变成你修改的样式了
What you described above is a custom pop-up style, which is no problem. Imagine if you customize a pop-up style, but some internal parameters need to be assigned according to actual use, for example, I need to give a title tag to the pop-up frame, or I need to change the color of a certain style, and so on. How should these be implemented? In the wpf version of prism, it is possible to modify it according to the style, but the avalonia version of prism does not support it. Although I have implemented it through other ways, it is very troublesome
是的,它还不够完美,我也试图只通过样式来修改,但是它不起作用,确实这种方法比较麻烦