feat: add separator support, fix various issues.
This commit is contained in:
@@ -9,17 +9,22 @@ namespace Ursa.Demo.Converters;
|
||||
|
||||
public class ToolBarItemTemplateSelector: IDataTemplate
|
||||
{
|
||||
|
||||
public static ToolBarItemTemplateSelector Instance { get; } = new();
|
||||
public Control? Build(object? param)
|
||||
{
|
||||
if (param is null) return null;
|
||||
if (param is ToolBarSeparatorViewModel sep)
|
||||
{
|
||||
return new ToolBarSeparator();
|
||||
}
|
||||
if (param is ToolBarButtonItemViewModel vm)
|
||||
{
|
||||
return new Button()
|
||||
{
|
||||
[!ContentControl.ContentProperty] = new Binding() { Path = "Content" },
|
||||
[!Button.CommandProperty] = new Binding() { Path = "Command" },
|
||||
//[!ToolBar.OverflowModeProperty] = new Binding(){ Path = "OverflowMode" }
|
||||
[!ToolBar.OverflowModeProperty] = new Binding(){Path = nameof(ToolBarItemViewModel.OverflowMode)},
|
||||
};
|
||||
}
|
||||
if (param is ToolBarCheckBoxItemViweModel cb)
|
||||
@@ -28,7 +33,7 @@ public class ToolBarItemTemplateSelector: IDataTemplate
|
||||
{
|
||||
[!ContentControl.ContentProperty] = new Binding() { Path = "Content" },
|
||||
[!ToggleButton.IsCheckedProperty] = new Binding() { Path = "IsChecked" },
|
||||
//[!ToolBar.OverflowModeProperty] = new Binding(){ Path = "OverflowMode" }
|
||||
[!ToolBar.OverflowModeProperty] = new Binding(){Path = nameof(ToolBarItemViewModel.OverflowMode)},
|
||||
};
|
||||
}
|
||||
if (param is ToolBarComboBoxItemViewModel combo)
|
||||
@@ -38,7 +43,7 @@ public class ToolBarItemTemplateSelector: IDataTemplate
|
||||
[!ContentControl.ContentProperty] = new Binding() { Path = "Content" },
|
||||
[!SelectingItemsControl.SelectedItemProperty] = new Binding() { Path = "SelectedItem" },
|
||||
[!ItemsControl.ItemsSourceProperty] = new Binding() { Path = "Items" },
|
||||
[ToolBar.OverflowModeProperty] = OverflowMode.Always,
|
||||
[!ToolBar.OverflowModeProperty] = new Binding(){Path = nameof(ToolBarItemViewModel.OverflowMode)},
|
||||
};
|
||||
}
|
||||
return new Button() { Content = "Undefined Item" };
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
DockPanel.Dock="Top"
|
||||
Header="Hello World">
|
||||
<Button Content="Button 1" u:ToolBar.OverflowMode="Never" />
|
||||
<u:ToolBarSeparator/>
|
||||
<Button u:ToolBar.OverflowMode="AsNeeded" Content="Button 2" />
|
||||
<Button u:ToolBar.OverflowMode="AsNeeded" Content="Button 3" />
|
||||
<ToggleButton Content="Toggle"></ToggleButton>
|
||||
</u:ToolBar>
|
||||
<u:ToolBar
|
||||
HorizontalAlignment="Left"
|
||||
|
||||
@@ -17,11 +17,13 @@ public partial class ToolBarDemoViewModel: ObservableObject
|
||||
new ToolBarButtonItemViewModel() { Content = "Open" },
|
||||
new ToolBarButtonItemViewModel() { Content = "Save1" },
|
||||
new ToolBarButtonItemViewModel() { Content = "Save2" },
|
||||
new ToolBarSeparatorViewModel(),
|
||||
new ToolBarButtonItemViewModel() { Content = "Save3" },
|
||||
new ToolBarButtonItemViewModel() { Content = "Save4" },
|
||||
new ToolBarButtonItemViewModel() { Content = "Save5" },
|
||||
new ToolBarButtonItemViewModel() { Content = "Save6" },
|
||||
new ToolBarButtonItemViewModel() { Content = "Save7" },
|
||||
new ToolBarSeparatorViewModel(),
|
||||
new ToolBarButtonItemViewModel() { Content = "Save8" },
|
||||
new ToolBarCheckBoxItemViweModel() { Content = "Bold" },
|
||||
new ToolBarCheckBoxItemViweModel() { Content = "Italic", OverflowMode = OverflowMode.Never},
|
||||
@@ -73,7 +75,9 @@ public class ToolBarComboBoxItemViewModel: ToolBarItemViewModel
|
||||
MessageBox.ShowOverlayAsync(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class ToolBarSeparatorViewModel: ToolBarItemViewModel
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user