ContentView doesn't show ContentControl

Hi,

i got a short question about theSfNavigationDrawer.ContentView. I use Prism and want to add to the ContentView to a Prism Region. Does the ContentView doesn't support ContentControls?
My code snippet:


        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>

            <sf:SfNavigationDrawer x:Name="drawer"
                IsOpen="True"
                DrawerWidth="300"
                Position="Left"
                TouchThreshold="35"
                Transition="Push">
                <sf:SfNavigationDrawer.DrawerHeaderView>
                    <Grid Background="{DynamicResource HeaderBackgroundColor}"
                        Height="120">
                        <Border BorderBrush="{DynamicResource BorderColor}" BorderThickness="1,0,1,1" />
                        <Image Source="/Sample.Desktop;component/Resources/icon.png" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Fill" Width="100" Height="100" />
                    </Grid>
                </sf:SfNavigationDrawer.DrawerHeaderView>
                <sf:SfNavigationDrawer.DrawerContentView>
                    <Grid>
                        <Border BorderBrush="{DynamicResource BorderColor}" BorderThickness="1,0,1,1" />
                        <ListBox Padding="0,8,0,0" 
                            Background="White"
                            ItemsSource="{Binding Menu}"
                            ItemContainerStyle="{StaticResource listboxitemStyle}" Margin="5">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <sf:NavigationItem Command="{Binding DataContext.NavigationCommand, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" 
                                        CommandParameter="{Binding}"
                                        IconMemberPath="{Binding IconSource}"
                                        Header="{Binding Header}" />
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </Grid>
                </sf:SfNavigationDrawer.DrawerContentView>
                <sf:SfNavigationDrawer.ContentView>
                    <ContentControl Grid.Column="1" prism:RegionManager.RegionName="ContentRegion" />
                </sf:SfNavigationDrawer.ContentView>
            </sf:SfNavigationDrawer>
            
            <ContentControl Grid.Column="1" prism:RegionManager.RegionName="ContentRegion" />

        </Grid>


Best regards
Andreas

3 Replies 1 reply marked as answer

SP Sakthivel Palaniyappan Syncfusion Team January 3, 2021 03:29 PM UTC

Hi Andreas,

Greetings from Syncfusion.

We have analyzed the reported issue. We have prepared a sample based on the information provided. We have tried to replicate the reported issue at our end, we are afraid that we are not able to reproduce the issue at our end. We have attached sample for your reference.

Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/NavigationDrawer_ContentView-1361779406.zip

Since we are not aware of your exact application scenario, we were not able to reproduce this issue at our end, so can you please provide complete runnable sample. This will be helpful for us to investigate further and provide you a better solution at the earliest.

Regards,
Sakthivel P.
 



AS Andreas Sprengard January 4, 2021 10:17 AM UTC

Hi Sakthivel,

i found out that the Parent object is null and the region needs to be registered.

MainWindow.xaml.cs:

        public MainWindow(IRegionManager regionManager)
        {
            InitializeComponent();

            var parent = LogicalTreeHelper.GetParent(this.contentRegionControl);

            if (regionManager != null)
            {
                SetRegionManager(regionManager, this.contentRegionControl, "ContentRegion");
            }
        }

        void SetRegionManager(IRegionManager regionManager, DependencyObject regionTarget, string regionName)
        {
            RegionManager.SetRegionName(regionTarget, regionName);
            RegionManager.SetRegionManager(regionTarget, regionManager);
        }

Attached a sample app.

Best regards
Andreas

Attachment: PrismNavigationDrawer_f2060803.zip


SS Suganya Sethuraman Syncfusion Team January 5, 2021 12:10 PM UTC

Hi Andreas,

 We have analyzed the reported issue. We have modified the sample based on your requirement.

Code Snippet:
 
        private readonly IRegionManager _regionManager; 
        public MainWindow(IRegionManager regionManager) 
        { 
            InitializeComponent(); 
            _regionManager = regionManager; 
            var parent = LogicalTreeHelper.GetParent(this.contentRegionControl); 
 
            if (regionManager != null) 
            { 
                SetRegionManager(regionManager, this.contentRegionControl, "ContentRegion"); 
            } 
 
            _regionManager.RequestNavigate("ContentRegion", "FileExplorerView"); 
        } 

Please have the modified sample for your reference,

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/PrismNavigationDrawer-183445399

Please check if the sample satisfies your requirement and let us know if you have any concerns.

Regards,
Suganya Sethuraman.
 


Marked as answer
Loader.
Up arrow icon