private ServerGroup selectedGroup;
public ServerGroup SelectedGroup
{
get => selectedGroup;
set
{
selectedGroup = value;
loadProcesses();
}
}
public ObservableCollection<ServerGroup> Groups { get; }
public ObservableCollection<Process> Processes { get; }
private async void loadProcesses()
{
Processes.Clear();
//get response from API, etc.
var response = new List<Process>(); //example
response.ForEach(Processes.Add);
}
<ComboBox SelectedItem="{Binding SelectedGroup}" ItemsSource="{Binding Groups}"/>
<ComboBox SelectedItem="{Binding ......}" ItemsSource="{Binding Processes}"/>
public MyClass()
{
MyCommand = new DelegateCommand(AnyAction);
}
public ICommand MyCommand {get;}
void AnyAction()
{
//code
}
<Image
x:Class="Malinka.Controls.BackgroundImage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="imageBase"
mc:Ignorable="d"
Source="{Binding Settings.ImagePath, ElementName=imageBase, Converter={StaticResource BackgroundImageConverter}}"
Stretch="UniformToFill">
<Image.Effect>
<BlurEffect Radius="{Binding Settings.Blur, ElementName=imageBase}"/>
</Image.Effect>
</Image>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button Content="Change color"
Click="Button_Click"
Margin="15"/>
<Rectangle Name="MyRectangle"
Grid.Row="1"
Margin="15"
Fill="Red"/>
</Grid>
private List<SolidColorBrush> brushes;
private Random rnd;
public MainWindow()
{
InitializeComponent();
rnd = new Random();
brushes = new List<SolidColorBrush> //заполняем цвета, которые будет принимать Rectangle
{
Brushes.AliceBlue,
Brushes.AntiqueWhite,
Brushes.Aqua,
Brushes.Aquamarine
};
}
private void Button_Click(object sender, RoutedEventArgs e)
{
MyRectangle.Fill = brushes[rnd.Next(0, brushes.Count)];
}
<Button x:Name="AddField"
Width="103"
Height="25"
Margin="15"
HorizontalAlignment="Right"
Content="Добавить поле">
<Button.ContextMenu>
<ContextMenu ItemsSource="{Binding MenuItems}"/>
</Button.ContextMenu>
</Button>
public class MainVM
{
public List<MenuItem> MenuItems { get; set; }
public MainVM()
{
MenuItems = new List<MenuItem>()
{
new MenuItem() { Header = "Автор", Command = Author},
new MenuItem() { Header = "Версия"},
new MenuItem() { Header = "Лицензия"},
new MenuItem() { Header = "Авторские права"},
new MenuItem() { Header = "Официальный сайт"},
new MenuItem() { Header = "Лицензионный ключ"},
new MenuItem() { Header = "Источник"},
new MenuItem() { Header = "Хеш-суммы"}
};
}
public ICommand Author => new DelegateCommand(() =>
{
MessageBox.Show("Author");
});
}