** THIS SITE IS AN ARCHIVE ** - New Content is at:
Written by: kchristo Thursday, July 12, 2012
public static void AddLogo(this Microsoft.LightSwitch.Client.IClientApplication application, System.Windows.HorizontalAlignment alignment, string screenName) { Microsoft.LightSwitch.Threading.Dispatchers.Main.BeginInvoke(() => { LogoPlacement.AddLogo(application, System.Windows.Application.Current.RootVisual, alignment, screenName); });}private static class LogoPlacement{ internal static void AddLogo(Microsoft.LightSwitch.Client.IClientApplication application, UIElement element, System.Windows.HorizontalAlignment alignment, string screenName) { if (rcb != null) return; for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(element); i++) { if (rcb != null) return; UIElement child = (UIElement)System.Windows.Media.VisualTreeHelper.GetChild(element, i); AddLogo(application, child, alignment, screenName); } if (element is Microsoft.LightSwitch.Runtime.Shell.Implementation.Standard.RibbonCommandBar) { rcb = element as Microsoft.LightSwitch.Runtime.Shell.Implementation.Standard.RibbonCommandBar; Image myImage = new Image() { Stretch = System.Windows.Media.Stretch.Uniform, Margin = new Thickness(2, 8, 14, 8), HorizontalAlignment = alignment, Cursor = System.Windows.Input.Cursors.Hand }; myImage.SetValue(ComponentViewModelService.ViewModelNameProperty, "Default.LogoViewModel"); myImage.SetBinding(Image.SourceProperty, new System.Windows.Data.Binding { Path = new PropertyPath("Logo") }); if (!string.IsNullOrWhiteSpace(screenName)) myImage.MouseLeftButtonUp += (s, e) => { application.Details.Dispatcher.BeginInvoke(() => application.Details.Methods[string.Format("Show{0}", screenName)].CreateInvocation().Execute()); }; myImage.SizeChanged += (s, e) => { double left = (s as Image).HorizontalAlignment == HorizontalAlignment.Left ? e.NewSize.Width + 10.0 : 0.0; double right = (s as Image).HorizontalAlignment == HorizontalAlignment.Right ? e.NewSize.Width + 10.0 : 0.0; rcb.Padding = new Thickness(left, 0, right, 0); }; ((Grid)rcb.Parent).Children.Add(myImage); } }
1 comment(s) so far...
NFL JerseysNFL Jerseys ChinaCheap JerseysMLB StoreNFL Football JerseysNFL ApparelCheap Jerseys From ChinaNFL JerseysNFL JerseyNFL Fan ShopNFL Fan ShopMLB JerseysCheap NBA Jerseys From ChinaNFL Shop OnlineMLB ShopsCheap Football JerseysNFL JerseysCheap NBA Jerseys From ChinaJerseys CheapestMLB JerseysWholesale NFL JerseysNFL Jersey SalesMLB Shop OnlineNFL JerseysOfficial NFL ShopNBA JerseyCustom NBA JerseysNFL JerseyNFL JerseysCheap NHL Jerseys ChinaCheap NBA JerseysCheap Jerseys From ChinaCheap NHL Hockey JerseysNHL Jerseys CheapBaseball JerseysMLB Store Official SiteCustom NBA JerseysNHL Jerseys WholesaleNHL StoreNBA ShopCheap JerseysCheap NFL JerseysWholesale JerseysCheap Jerseys WholesaleBest NFL Jerseys