DetailImageView hides shadows for empty items

This commit is contained in:
Justin Swanson 2019-11-16 23:31:54 -06:00
parent f2c15bccce
commit 4268d1b9b8
2 changed files with 42 additions and 13 deletions

View File

@ -1,4 +1,4 @@
<UserControl
<local:UserControlRx
x:Class="Wabbajack.DetailImageView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -97,7 +97,8 @@
FontWeight="Bold"
Style="{StaticResource BackgroundBlurStyle}"
Text="{Binding Title, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
TextWrapping="WrapWithOverflow">
TextWrapping="WrapWithOverflow"
Visibility="{Binding ShowTitle, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource bool2VisibilityHiddenConverter}}">
<TextBlock.Effect>
<BlurEffect Radius="85" />
</TextBlock.Effect>
@ -113,7 +114,8 @@
FontSize="30"
FontWeight="Bold"
Style="{StaticResource BackgroundBlurStyle}"
TextWrapping="WrapWithOverflow">
TextWrapping="WrapWithOverflow"
Visibility="{Binding ShowAuthor, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource bool2VisibilityHiddenConverter}}">
<TextBlock.Effect>
<BlurEffect Radius="55" />
</TextBlock.Effect>
@ -130,7 +132,8 @@
FontSize="65"
FontWeight="Bold"
Text="{Binding Title, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
TextWrapping="WrapWithOverflow">
TextWrapping="WrapWithOverflow"
Visibility="{Binding ShowTitle, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource bool2VisibilityHiddenConverter}}">
<TextBlock.Effect>
<DropShadowEffect />
</TextBlock.Effect>
@ -142,7 +145,8 @@
FontFamily="Lucida Sans"
FontSize="30"
FontWeight="Bold"
TextWrapping="Wrap">
TextWrapping="Wrap"
Visibility="{Binding ShowAuthor, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource bool2VisibilityHiddenConverter}}">
<TextBlock.Effect>
<DropShadowEffect />
</TextBlock.Effect>
@ -163,7 +167,8 @@
Style="{StaticResource BackgroundBlurStyle}"
Text="{Binding Description, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
TextAlignment="Right"
TextWrapping="Wrap">
TextWrapping="Wrap"
Visibility="{Binding ShowDescription, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource bool2VisibilityHiddenConverter}}">
<TextBlock.Effect>
<BlurEffect Radius="55" />
</TextBlock.Effect>
@ -179,7 +184,8 @@
FontSize="16"
Text="{Binding Description, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
TextAlignment="Right"
TextWrapping="Wrap">
TextWrapping="Wrap"
Visibility="{Binding ShowDescription, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource bool2VisibilityHiddenConverter}}">
<TextBlock.Effect>
<DropShadowEffect />
</TextBlock.Effect>
@ -192,4 +198,4 @@
Grid.ColumnSpan="2"
Fill="Transparent" />
</Grid>
</UserControl>
</local:UserControlRx>

View File

@ -1,6 +1,8 @@
using System;
using ReactiveUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@ -18,7 +20,7 @@ namespace Wabbajack
/// <summary>
/// Interaction logic for DetailImageView.xaml
/// </summary>
public partial class DetailImageView : UserControl
public partial class DetailImageView : UserControlRx
{
public ImageSource Image
{
@ -42,7 +44,7 @@ namespace Wabbajack
set => SetValue(TitleProperty, value);
}
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(nameof(Title), typeof(string), typeof(DetailImageView),
new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, WireNotifyPropertyChanged));
public string Author
{
@ -50,7 +52,7 @@ namespace Wabbajack
set => SetValue(AuthorProperty, value);
}
public static readonly DependencyProperty AuthorProperty = DependencyProperty.Register(nameof(Author), typeof(string), typeof(DetailImageView),
new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, WireNotifyPropertyChanged));
public string Description
{
@ -58,11 +60,32 @@ namespace Wabbajack
set => SetValue(DescriptionProperty, value);
}
public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register(nameof(Description), typeof(string), typeof(DetailImageView),
new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, WireNotifyPropertyChanged));
private readonly ObservableAsPropertyHelper<bool> _ShowAuthor;
public bool ShowAuthor => _ShowAuthor.Value;
private readonly ObservableAsPropertyHelper<bool> _ShowDescription;
public bool ShowDescription => _ShowDescription.Value;
private readonly ObservableAsPropertyHelper<bool> _ShowTitle;
public bool ShowTitle => _ShowTitle.Value;
public DetailImageView()
{
InitializeComponent();
this._ShowAuthor = this.WhenAny(x => x.Author)
.Select(x => !string.IsNullOrWhiteSpace(x))
.ToProperty(this, nameof(this.ShowAuthor));
this._ShowDescription = this.WhenAny(x => x.Description)
.Select(x => !string.IsNullOrWhiteSpace(x))
.ToProperty(this, nameof(this.ShowDescription));
this._ShowTitle = this.WhenAny(x => x.Title)
.Select(x => !string.IsNullOrWhiteSpace(x))
.ToProperty(this, nameof(this.ShowTitle));
}
}
}