Answer the question
In order to leave comments, you need to log in
How to get all elements from wrappanel?
How to access each WrapPanel element and change the Background?
Code example:
public void AddTabMenu()
{
var lb = new Label();
var index = wpTopMenu.Children.Count;
lb.Name = "Scene" + index;
lb.Content = "Сцена " + index;
lb.Style = this.Resources["tabMenu"] as Style;
wpTopMenu.Children.Insert(index - 1, lb);
}
private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
AddTabMenu();
}
private void Label_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if(sender is Label lb)
{
var index = wpTopMenu.Children.Count;
for (int i = 0; i < index; i++)
{
var item = wpTopMenu.Children[i];
}
lb.Background = new SolidColorBrush(Color.FromArgb(255, 136, 0, 255));
br.Children.RemoveAt(0);
}
}
Answer the question
In order to leave comments, you need to log in
Assign a Background resource or a style to an element that refers to the Background,
then just change the color of the resource when necessary
Example code:
App.xaml
<Color x:Key="DecorateColor">#FF005087</Color>
<SolidColorBrush x:Key="BackgroundBrush" Color="{DynamicResource DecorateColor}"/>
Color decorateColor = Color.Color.FromArgb(255, 136, 0, 255);
Application.Current.Resources["DecorateColor"] = decorateColor;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question