Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ComboBoxData : BaseViewModel
- {
- private Brush _labelsColor;
- private string _textConst;
- public Brush LabelsColor
- {
- get => _labelsColor;
- private set => Set(ref _labelsColor, value);
- }
- public string TextConst
- {
- get => _textConst;
- private set => Set(ref _textConst, value);
- }
- public ComboBoxData(Brush color, string text)
- {
- LabelsColor = color;
- TextConst = text;
- }
- }
- //===========================================
- public class EditTaskWindowViewModel : BaseViewModel
- {
- private List<ComboBoxData> _cbData;
- private ComboBoxData _cbSolo;
- public ComboBoxData cbSolo
- {
- get => _cbSolo;
- set => Set(ref _cbSolo, value);
- }
- public List<ComboBoxData> CBData
- {
- get => _cbData;
- set => Set(ref _cbData, value);
- }
- public EditTaskWindowViewModel()
- {
- CBData = new List<ComboBoxData>();
- InitializecbData(0, 148, 204, "Will definitely happen"); //new Color(#0094cc)
- InitializecbData(0, 178, 72, "Need to do"); //Brushes(#00b248)
- InitializecbData(249, 168, 37, "It is desirable to do"); //Brushes(#f9a825)
- }
- private void InitializecbData(byte r, byte g, byte b, string text)
- {
- Color tmpColor = new Color();
- tmpColor.G = g;
- tmpColor.R = r;
- tmpColor.B = b;
- SolidColorBrush tmpSolidBrush = new SolidColorBrush(tmpColor);
- Brush tmpBrush = tmpSolidBrush;
- ComboBoxData cbd = new ComboBoxData(tmpBrush, text);
- CBData.Add(cbd);
- }
- }
- //===========================================
- <ComboBox Height="28" Margin="50,48,25,124" ItemsSource="{Binding CBData}" SelectedItem="{Binding cbSolo}">
- <ComboBox.ItemTemplate>
- <DataTemplate>
- <StackPanel Orientation="Horizontal">
- <Rectangle Height="10" Width="10" Margin="3, 0">
- <Rectangle.Fill>
- <SolidColorBrush Color="{Binding LabelsColor}"/>
- </Rectangle.Fill>
- </Rectangle>
- <TextBlock Text="{Binding TextConst}"></TextBlock>
- </StackPanel>
- </DataTemplate>
- </ComboBox.ItemTemplate>
- </ComboBox>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement