iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I have a custom implementation of the UXDesktop control that overrides the GetContainerForItemOverride() method. In that method, I create new UXWindow objects and set some default properties and command bindings. That has worked great up until now. I have new requirements now to have the desktop generate UXWindows for some bound items in the ItemsSource, but also generate UXNavigationWindows for other items in the ItemsSource.
Ideally, I'd like to be able to check for a property on each item being bound before creating the new window object. The item would have a property telling the desktop what type of window to generate.
What is the best way to accomplish this?
I've come up with a solution that works. I noticed that the IsItemItsOwnContainerOverride(object item) method always gets called before GetContainerForItemOverride(). Since the first method takes the item the window is bound to as a parameter, I can use the bound item to determine how to set a local variable in my inherited desktop specifying the type of window to be created next. Then I just check that variable to determine if I should generated a UXWindow or a UXNavigationWindow or a UXChromeWindow.
Here is a simplified psuedo code example:
//This class is the item bound to the window from the ItemsSourcepublic class WindowItem
{
bool IsNavigationWindow {get;set;}
}
//This is the custom implementation of the UXDesktoppublic class MyCustomDesktop : UXDesktop
//This enumeration defines the types of windows supportedpublic enum WindowType
Window,
NavigationWindow,
ChromeWindow
//This keeps track of the type of window to be generated nextprivate WindowType NewWindowType = WindowType.Window;
protected override bool IsItemItsOwnContainer(object item)
if (item is WindowItem)
if (((WindowItem)item).IsNavigationWindow)
NewWindowType = WindowType.NavigationWindow;
else
NewWindowType = WindowType.Window;
return base.IsItemItsOwnContainerOverride(item);
protected override DependencyObject GetContainerForItmeOverride()
UXWindow newWindow = null;
if (NewWindowType == WindowType.NavigationWindow)
newWindow = new UXNavigationWindow();
newWindow = new UXWindow();
...
Any idea if this is possible? Do I need to use a custom ItemsContainerGenerator or something?
Hello Chris,
Regarding this scenario, I would need a little more time to discuss with our developer teams. We would suggest what is the best approach for your scenario. I will be back asap.
Regards,Handy
Thanks. Let me know as soon as you have a solution as my project is in urgent need of this capability.
Hi Chris,
You've got it right, thanks for sharing your solution. That is the technique to create custom item type in an items control.
In another common scenario related to style customization, you may want to use ItemContainerStyleSelector of the control when you need to customize the style of the same target item type based on specific conditions. This allows you to perform the style conditioning in a separate class without have to override the control's class. More information and example about ItemContainerStyleSelector can be found here.
Hope this helps,Jimmy
I'm actually already using both an ItemContainerStyleSelector and an ItemContainerTemplateSelector so I can have different styles and datatemplates for UXWindows, UXNavigationWindows and UXChrome windows. Everything seems to be working fine now. Thanks for confirming that I found the right solution.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname