Hi there
I'm trying to implement Tabbed UI in windows app
SfTabItemExt Class
public class SfTabItemExt : SfTabItem
{
public string Name { get; set; }
}
Add TabItem in TabView
SfTabItemExt newtab = new() { Name = item.CtlName, Header = item.Title, Content = ctl };
tabView.Items.Add(newtab);
newtab.IsVisible = true;
newtab.Focus();
Child.Add(item.CtlName, item.Title);I'm not able to set focus on new tab item added
Similarly if ContentView I'm trying to add is already in TabView then it should bring the same in front.
public bool CheckItem(string Name, bool SetFocus = true)
{
if (Child.ContainsKey(Name))
{
if (SetFocus)
{
foreach (object item in tabView.Items)
{
SfTabItemExt Temp = (SfTabItemExt)item;
if (Temp.Name == Name) { Temp.IsVisible=true; Temp.Focus(); break; }
}
}
return true;
}
else return false;
}
Where am I getting wrong.
Please help
Amit Saraf
Hi Amit Saraf,
Query : Select perticular tabitem if index is not known
We have reviewed your query and, based on the provided information, we have created a sample that includes the SfTabView. We would like to inform you that we are unable to select a particular tab item using focus; we can only use the SelectedIndex property to select a tab item in the SfTabView. If the selected index is not known, you can get the selected index using the IndexOf the particular tab item, as demonstrated in the code snippet below. We have attached the sample for your reference. Please review it and let us know the details.
Code Snippet :
|
Mainpage.xaml
private void Button_Clicked(object sender, EventArgs e) { CustomContentView item = new CustomContentView(); item.Content = new Label() { Text = "This is Contentview", TextColor = Colors.Red }; SfTabItemExt newtab = new SfTabItemExt() { Name = item.Title, Header = item.Ctrl, Content = item }; tabView.Items.Add(newtab); // if the selected index is not known , you can get the selectedindex of the latesly added tab item using index of tabView.SelectedIndex = tabView.Items.IndexOf(newtab); } |
If your requirement is different from the suggested solution, please provide the sample that you have used to help us understand your needs.
Regards,
Ahamed Ali Nishad.
Thanks for your help
This solution has solved my problem.
Hi Amit,
You're welcome.
We are glad that the provided response
meets your requirement. Please let us know if you need further assistance. As
always, we are happy to help you out.
Regards,
Preethi R