У меня есть счетчик под названием TurnNumber. Это число меняется динамически в зависимости от кнопок в верхней части экрана. Я хочу изменить цвет фона вкладки, индекс которой равен TurnNumber.
Это то, что у меня есть на данный момент
MainWindowView:
Код: Выделить всё
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DndBattleHelper"
mc:Ignorable="d"
Title="DnD Battle Helper" Height="450" Width="800"
xmlns:VM="clr-namespace:DndBattleHelper.ViewModels"
xmlns:Views="clr-namespace:DndBattleHelper.Views"
xmlns:Converters="clr-namespace:DndBattleHelper.Views.Converters"
Name="main">
Код: Выделить всё
public class TwoEqualNumbersToBooleanConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (values.Length < 2)
return false;
int number1 = (int)values[0];
int number2 = (int)values[1];
// Return true if the tab index matches the TurnNumber
return number1 == number2;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
Когда TurnNumber = 0
Однако все элементы вкладки становятся красными, а не только тот, индекс которого равен TurnNumber.< /p>
Я также хотел бы, чтобы это переопределяло цвета SelectedTab, чтобы выбранная вкладка была стандартным серым, вкладка TurnNumber была красной, но если вкладка TurnNumber также является выбранной вкладкой, то это Красный. В настоящее время серый имеет приоритет над красным.
Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/790 ... s-a-differ