Selected sfTabItem from ViewModel

I have an sfDataGrid, and the selected item is captured by an ICommand in the ViewModel. Once I have the selected item, I want to open an sfTabItem to display the selected item details. Is this possible?

13 Replies 1 reply marked as answer

SP Sakthivel Palaniyappan Syncfusion Team February 16, 2021 06:27 PM UTC

Hi Robert,

Greetings from Syncfusion.

We have analyzed your query and created sample, based on your requirement and please find the sample from below.

Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/TabViewGrid-183771211.zip

Please let us know if you have any other queries.

Regards,
Sakthivel P.



RK Robert Kamarowski February 17, 2021 02:30 PM UTC

The example uses Navigation from the MainPage.xaml.cs. I would like to do this from the ViewModel, not in code behind.

I have: 
     LensesPage.xaml
     LensesPage.xaml.cs
     LensesPageViewModel.cs <-- this is where I want to call the details page from

I hope I'm making myself clear...



RS Ruba Shanmugam Syncfusion Team February 19, 2021 04:02 PM UTC

Hi Robert,

We have created sample based on your requirement and please find the sample from below link

Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/TabviewDataGridNavigation1071286315

In this sample, we have added INavigation to navigate the page in view model as like below code snippet

public INavigation Navigation
{
         get { return navigation; }
         set { navigation = value; }
}

public OrderInfoRepository(INavigation _navigation)
{
      navigation = _navigation;
 


Please check with the above sample and let us know if you have any concern.

Regards,
Ruba Shanmugam


RK Robert Kamarowski February 21, 2021 01:53 PM UTC

Thank you for the example. But it goes from one page to another. I want to go from one TabItem to another TabItem. And I would like to do this from the ViewModel, not the code behind (viewpage.xaml.cs).


SP Sakthivel Palaniyappan Syncfusion Team February 22, 2021 06:58 AM UTC

Hi Robert,

Thanks for the update.

We have analyzed your query created sample based on your provided information. Please find the sample from below.

We have added DataGrid control to the SfTabItem content in this sample, and when selecting the DataGrid item, the new TabItem creates and adds the selected item to the tab items.

Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/TabviewDataGridSample-1036205274.zip

Please check the sample if it meets your requirements. If your requirement is different from this please provide more details about your requirement.

Regards,
Sakthivel P.
 



RK Robert Kamarowski February 22, 2021 01:55 PM UTC

Thank you!


SP Sakthivel Palaniyappan Syncfusion Team February 23, 2021 04:31 AM UTC

Hi Robert,

Thanks for the update.

Please let us know if you need any other assistance on this.

Regards,
Sakthivel P.



RK Robert Kamarowski March 1, 2021 04:44 PM UTC

This is exactly what I'm trying to achieve, but I'm having a difficult time getting it to work.
Your example runs from the MainPage. However, my main page has a button that is selected that goes to another page. It's there that I want to use the tab items. If I don't set the TabItemPage.xaml.cs BindingContext to the ViewModel, the ViewModel doesn't get executed. If I set the BindingContext to the ViewModel, the datagrid in the TabItemPage can't be added to the TabItems. What am I doing wrong?


SP Sakthivel Palaniyappan Syncfusion Team March 2, 2021 03:15 PM UTC

Hi Robert Kamarowski,

Thanks for the update.

We have analyzed your query and we could not obtain exact issue of your scenario. Could you please modify the previous sample with reported issue and revert us? It will help us to find the root cause of an issue and provide better solution at the earliest.

Regards,
Sakthivel P.



RK Robert Kamarowski March 2, 2021 06:29 PM UTC

It said the zip file was too big, so I just zipped the changed files.

Attachment: HomePage.xaml_136becdc.zip


SP Sakthivel Palaniyappan Syncfusion Team March 3, 2021 08:37 AM UTC

Hi Robert Kamarowski,

Thanks for the update.

We have modified the sample with your provided files  and please download the sample from below.

Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/TabviewDataGrid-229705588.zip

Please let us know if you need further assistance on this.

Regards,
Sakthivel P.
 


Marked as answer

RK Robert Kamarowski March 3, 2021 02:45 PM UTC

Once again, thank you.


RS Ruba Shanmugam Syncfusion Team March 4, 2021 01:07 PM UTC

Hi Robert Kamarowski,

Thanks for the update. . Please let us know if you need further assistance.

Regards,
Ruba Shanmugam

Loader.
Up arrow icon