I am creating a Pro SDK 2.9 add-in that utilizes a dockpane. I have my dockpane set up with tabs similar to the Esri Custom Catalog sample (https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Framework/CustomCatalog) and each tab displays a custom control, similar to how each tab in the sample displays a string. One custom control contains a button that when clicked should replace the current custom control with a new one.
For example, the original custom control lists all current projects and also has a button that says "Create New Project". When that button is clicked, I want a new custom control that contains all the project options to appear and for the list of projects to no longer be visible. I have created the xaml for this replacement custom control and call it via the button ICommand, but nothing ever displays.
Below is the code from the MyProjectViewModel which is a PanelViewModelBase class (see sample).
private CreateProjectViewModel _createProjectPanel;
public MyProjectsViewModel()
{
_createProjectPanel = new CreateProjectViewModel();
_createProjectCommand = new RelayCommand(() => CreateProject(), () => true);
}private readonly ICommand _createProjectCommand;
public ICommand CreateProjectCommand => _createProjectCommand;private void CreateProject()
{
// this doesn't work
ProjectsViewModel pvm = new ProjectsViewModel();
pvm.SelectedProjectsPanelHeaderIndex = 0;
pvm.CurrentSubPanelPage = _createProjectPanel;
}
Here is the xaml code where I have the CreateProjectCommand and DataTemplate for the CreateProjectViewModel:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<extensions:DesignOnlyResourceDictionary Source="pack://application:,,,/ArcGIS.Desktop.Framework;component\Themes\Default.xaml"/>
</ResourceDictionary.MergedDictionaries>
<DataTemplate DataType="{x:Type viewModel:CreateProjectViewModel}">
<view:CreateProjectView/>
</DataTemplate>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Background="Transparent">
<DockPanel Margin="6,6" LastChildFill="True">
<TextBlock Style="{DynamicResource Esri_TextBlockRegular}" Margin="6,0,0,0">Sort By:</TextBlock>
<ComboBox ItemsSource="{Binding ProjectSortCriteria}" SelectedItem="{Binding SelectedSortCriteria, Mode=TwoWay}" SelectedIndex="0" Margin="6,0,0,0"></ComboBox>
</DockPanel>
</StackPanel>
<Grid Grid.Row="1" Background="Transparent">
<ListBox Name="MyProjectsListBox" Margin="6,0" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemContainerStyle="{DynamicResource Esri_ListBoxItemHighlightBrush}"
SelectedItem="{Binding Path=SelectedProjectName}" ItemsSource="{Binding Path=ProjectNames}" Grid.ColumnSpan="2">
<ListBox.Style>
<Style TargetType="{x:Type ListBox}">
</Style>
</ListBox.Style>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</Grid>
<StackPanel Grid.Row="2" Background="Transparent">
<Button Command="{Binding CreateProjectCommand}" Content="Create Project" Style="{DynamicResource Esri_Button}" Margin="10" HorizontalAlignment="Left"/>
</StackPanel>
</Grid>
Hi,
It looks like your solution adds a new tab, but I would like to replace or cover the content of an existing tab. For example, in the Custom Catalog sample, I would like to click the dockpane burger button menu item and that would replace the content of the current tab with new content. I hope that explains my issue better.
Thank you