-
-
Save milleniumbug/bf5be826d63d8b382f7349711ceb340a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Globalization; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows; | |
using System.Windows.Data; | |
using System.Windows.Media; | |
namespace Katas | |
{ | |
class BoolToColorConverter : IValueConverter | |
{ | |
public static readonly BoolToColorConverter Default = new BoolToColorConverter(); | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
return (bool) value ? Brushes.Blue : Brushes.HotPink; | |
} | |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
throw new NotSupportedException(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="Katas.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
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:Katas" | |
mc:Ignorable="d" | |
Title="MainWindow" Height="350" Width="525" DataContext="{Binding Source={RelativeSource Self}}"> | |
<Grid Background="{Binding IsChecked, ElementName=CheckBox, Converter={x:Static local:BoolToColorConverter.Default}}"> | |
<CheckBox x:Name="CheckBox" VerticalAlignment="Center" HorizontalAlignment="Center"/> | |
</Grid> | |
</Window> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment