private void OnTextChanged(string newValue, string oldValue) { var canvas = Canvas; if (canvas == null) { _text = newValue; return; } if (string.IsNullOrEmpty(newValue)) { canvas.Source = null; return; } if (oldValue != null) { if (string.Equals(newValue, oldValue, StringComparison.OrdinalIgnoreCase) || string.Equals(newValue, _text, StringComparison.OrdinalIgnoreCase)) { return; } } _text = newValue; var foreground = Colors.Black; var background = Colors.White; if (Foreground is SolidColorBrush foreBrush) { foreground = foreBrush.Color; } if (Background is SolidColorBrush backBrush) { background = backBrush.Color; } canvas.Source = PlaceholderHelper.GetQr(newValue, foreground, background); }