diff --git a/CPF.Toolkit.Demo/MainView.cs b/CPF.Toolkit.Demo/MainView.cs
index ea82b52..b385519 100644
--- a/CPF.Toolkit.Demo/MainView.cs
+++ b/CPF.Toolkit.Demo/MainView.cs
@@ -65,6 +65,16 @@ namespace CPF.Toolkit.Demo
Content = "关闭窗体",
Commands = { { nameof(Button.Click),(s,e) => vm.Test() } }
},
+ new Button
+ {
+ Content = "关闭窗体",
+ Commands = { { nameof(Button.Click),(s,e) => vm.Test() } }
+ },
+ new Button
+ {
+ Content = "loading",
+ Commands = { { nameof(Button.Click),(s,e) => vm.LoadingTest() } }
+ },
}
}));
}
diff --git a/CPF.Toolkit.Demo/MainViewModel.cs b/CPF.Toolkit.Demo/MainViewModel.cs
index 0aa3915..efe9c4d 100644
--- a/CPF.Toolkit.Demo/MainViewModel.cs
+++ b/CPF.Toolkit.Demo/MainViewModel.cs
@@ -24,5 +24,18 @@ namespace CPF.Toolkit.Demo
e.Cancel = !this.isClose;
base.OnClose(e);
}
+
+ public async void LoadingTest()
+ {
+ await this.ShowLoading(Task.Delay(3000));
+ this.Dialog.Sucess("test");
+
+ //var result = await this.ShowLoading(async () =>
+ //{
+ // await Task.Delay(5000);
+ // return "test";
+ //});
+ //this.Dialog.Sucess(result);
+ }
}
}
diff --git a/CPF.Toolkit/CPF.Toolkit.csproj b/CPF.Toolkit/CPF.Toolkit.csproj
index a49aac9..4e089e0 100644
--- a/CPF.Toolkit/CPF.Toolkit.csproj
+++ b/CPF.Toolkit/CPF.Toolkit.csproj
@@ -21,5 +21,7 @@
-
+
+
+
diff --git a/CPF.Toolkit/Dialogs/DialogView.cs b/CPF.Toolkit/Dialogs/DialogView.cs
index d1a76ee..8a752b0 100644
--- a/CPF.Toolkit/Dialogs/DialogView.cs
+++ b/CPF.Toolkit/Dialogs/DialogView.cs
@@ -97,38 +97,25 @@ namespace CPF.Toolkit.Dialogs
{ nameof(TextBox.Text),nameof(Text),this,BindingMode.OneWay}
}
}.Assign(out var textBox),
- //new Border
- //{
- // Attacheds = { { Grid.RowIndex,2 } },
- // BorderThickness = new Thickness(0,1,0,0),
- // BorderType = BorderType.BorderThickness,
- // BorderFill = "236,236,236",
- // Size = SizeField.Fill,
- // MarginBottom = 5,
- //},
new StackPanel
{
Height = "100%",
Attacheds = { { Grid.RowIndex,2 } },
MarginBottom = 4,
Orientation = Orientation.Horizontal,
- }.Assign(out var p),
+ }
+ .LoopCreate(this.Buttons.Length, i => new Button
+ {
+ Content = this.Buttons[i],
+ MinWidth = this.Buttons.Length <= 1 ? 80 : 65,
+ Background = "white",
+ BorderFill = "236,236,236",
+ Height = "95%",
+ MarginRight = 5,
+ Commands = { { nameof(Button.Click),(s,e) => this.DialogResult = i } }
+ }),
}
}));
-
- this.Buttons.Select(x => new Button
- {
- Content = x,
- MinWidth = this.Buttons.Length <= 1 ? 80 : 65,
- Background = "white",
- BorderFill = "236,236,236",
- Height = "95%",
- MarginRight = 5,
- }).ToList().ForEach(c =>
- {
- p.Children.Add(c);
- c.Click += Button_Click;
- });
textBox.TextChanged += TextBox_TextChanged;
}
@@ -147,12 +134,6 @@ namespace CPF.Toolkit.Dialogs
}
}
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- this.DialogResult = (sender as Button).Content;
- this.Close();
- }
-
protected override void OnKeyUp(KeyEventArgs e)
{
if (e.Key.Or(Keys.Enter, Keys.Space))
diff --git a/CPF.Toolkit/Dialogs/IClosable.cs b/CPF.Toolkit/Dialogs/IClosable.cs
index fec269a..374004d 100644
--- a/CPF.Toolkit/Dialogs/IClosable.cs
+++ b/CPF.Toolkit/Dialogs/IClosable.cs
@@ -8,7 +8,7 @@ namespace CPF.Toolkit.Dialogs
{
internal interface IClosable
{
- event EventHandler Closable;
+ event EventHandler