private static object GetButton(BindableApplicationBar bindableApplicationBar, object item) { var bindableButton = item as BindableApplicationBarIconButton; if (bindableButton != null) { bindableButton.DataContext = bindableApplicationBar.DataContext; bindableButton.DataItem = item; if (!string.IsNullOrEmpty(bindableApplicationBar.MenuItemClickMethodName)) { bindableButton.ClickMethodName = bindableApplicationBar.MenuItemClickMethodName; } return(bindableButton); } else if (item is ApplicationBarMenuItem) { return(item); } else { var textProperty = item.GetType().GetProperty(bindableApplicationBar.TextMemberPath); var menuItem = new BindableApplicationBarMenuItem(); menuItem.Text = textProperty.GetValue(item).ToString(); menuItem.DataContext = bindableApplicationBar.DataContext; menuItem.ClickMethodName = bindableApplicationBar.MenuItemClickMethodName; menuItem.DataItem = item; return(menuItem); } }
private static object GetMenuItem(BindableApplicationBar bindableApplicationBar, object item) { var bindableMenuItem = item as BindableApplicationBarMenuItem; if (bindableMenuItem != null) { bindableMenuItem.DataContext = bindableApplicationBar.DataContext; bindableMenuItem.DataItem = item; if (!string.IsNullOrEmpty(bindableApplicationBar.MenuItemClickMethodName)) { bindableMenuItem.ClickMethodName = bindableApplicationBar.MenuItemClickMethodName; } return bindableMenuItem; } else if (item is ApplicationBarMenuItem) { return item; } else { var textProperty = item.GetType().GetProperty(bindableApplicationBar.TextMemberPath); var menuItem = new BindableApplicationBarMenuItem(); menuItem.Text = textProperty.GetValue(item).ToString(); menuItem.DataContext = bindableApplicationBar.DataContext; menuItem.ClickMethodName = bindableApplicationBar.MenuItemClickMethodName; menuItem.DataItem = item; return menuItem; } }