▶NullToTrueConverter
public class NullToTrueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return true;
}
return false;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
▶xaml의 trigger에서의 예
: Binding되는 변수가 True일 경우에 특정 Template 적용되는 구문입니다.
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedValue, Converter={StaticResource NullToTrueConverter}}" Value="True">
<Setter Property="ContentTemplate" Value="{DynamicResource TestDataTemplate}"/>
</DataTrigger>
</Style.Triggers>