hi
i'm building kinda large scale wpf (with mvvm) project and i want to define some ToolBars for some different/logically separated views, then collected them in the application mainwindow(main view), here is one of them:
<UserControl
x:Class="SoilProfile.View.ReportEditToolbarView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:SoilProfile.View"
mc:Ignorable="d">
<ToolBar x:Name="EditToolbar"
Band="1" BandIndex="1">
<Button
ToolTip="Add New Page" Content="Add Page" />
<Button
ToolTip="Delete Page" Content="Delete Page" />
<Separator />
<Button
ToolTip="Add New Layer" Content="Add Layer" />
<Button
ToolTip="Delete Layer" Content="Delete Layer" />
<!--<Button ToolBar.OverflowMode="Always">
</Button>-->
</ToolBar>
</UserControl>
then in some view i want to use this toolbar, like:
/// <summary>
/// Interaction logic for ReportsView.xaml
/// </summary>
public partial class ReportView : UserControl, ViewInterface.IReport
{
private ReportVM _viewModel;
public ToolBar EditToobar { get; internal set; }
public ReportView(ReportVM viewModel)
{
// ...
#region initializes
var toolbarView = new ReportEditToolbarView();
EditToobar = toolbarView.EditToolbar;
toolbarView.Content = null;
#endregion
}
/ ...
then in the main window i have a
<ToolBarTray x:Name="toolBars"
and in code behind:
var reportVM = new ReportVM();
var reportView = new ReportView(reportVM);
this.toolBars.ToolBars.Add(reportView.EditToobar);
my questions are:
Q1: is that a good practice to use toolbar as a usercontrol.content (if not , what is the better way),
Q2: is it necessary to have ViewModel class for each view even simpler one (like a toolbar).
any suggesions will be appreciated,
thanks in advance.