Код: Выделить всё
public class Case : ContentControl
{
public static readonly DependencyProperty SwitchCaseProperty = DependencyProperty.Register("SwitchCase",
typeof(object), typeof(Case), new PropertyMetadata() { PropertyChangedCallback = OnPropChanged });
public object? SwitchCase
{
get => GetValue(SwitchCaseProperty);
set => SetValue(SwitchCaseProperty, value);
}
public object? SwitchValue { get; set; }
public object? SwitchContent { get; set; }
private static void OnPropChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is Case _case)
{
_case.Content = _case.SwitchCase.ToString() == _case.SwitchValue.ToString() ? _case.SwitchContent : null;
}
}
}
< /code>
реализация: < /p>
Идеи? /> cash.switchcase
ссылка на объект не установлен на экземпляр объекта < /p>
< /blockquote>
Подробнее здесь: https://stackoverflow.com/questions/797 ... on-in-xaml
Мобильная версия