I have this grid with button and labels :
-
"95" VerticalAlignment="Top" - Background="{StaticResource TopBar}">
- Content="" HorizontalAlignment="Left" Margin="1208,8.04,0,0" VerticalAlignment="Top" Width="185" Height="77" ToolTip="Main Catalogue " Cursor="Hand" Click="Button_Click"/>
-
"40" HorizontalAlignment="Left" Margin="20,20,0,0" VerticalAlignment="Top" Width="200" TextWrapping="Wrap" FontSize="21.333">"en-gb" Text="Promotions"/> - Content="" HorizontalAlignment="Left" Margin="304,8,0,0" VerticalAlignment="Top" Width="185" Height="77" ToolTip="Main Catalogue " Cursor="Hand" Click="Button_Click">
-
-
"/Images/LibraryCatalog.png" />
- public static T FindChild
(DependencyObject parent, string childName) - where T : DependencyObject
- {
- // Confirm parent and childName are valid.
- if (parent == null) return null;
- T foundChild = null;
- int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
- for (int i = 0; i < childrenCount; i++)
- {
- var child = VisualTreeHelper.GetChild(parent, i);
- // If the child is not of the request child type child
- T childType = child as T;
- if (childType == null)
- {
- // recursively drill down the tree
- foundChild = FindChild
(child, childName); - // If the child is found, break so we do not overwrite the found child.
- if (foundChild != null) break;
- }
- else if (!string.IsNullOrEmpty(childName))
- {
- var frameworkElement = child as FrameworkElement;
- // If the child's name is set for search
- if (frameworkElement != null && frameworkElement.Name == childName)
- {
- // if the child's name is of the request name
- foundChild = (T)child;
- break;
- }
- }
- else
- {
- // child element found.
- foundChild = (T)child;
- break;
- }
- }
- return foundChild;
- }
- private void Set_Language()
- {
- Label lblText = UIHelper.FindChild
- strLanguage = "LibraryAccess.Languages." + ((ComboBoxItem)ddlLanguage.SelectedItem).Name.ToString();
- ResourceManager LocRM = new ResourceManager(strLanguage, typeof(MainMenu).Assembly);
- if (lblText != null)
- {
- lblText.Content = LocRM.GetString("lblWebLinks");
- }
- }
please advise
Rahul BansalPosted May 12, 2016, 8:10 AM