Hide message tiles that doesn't have data available

This commit is contained in:
Morten 2015-05-29 09:50:14 -07:00
parent 694c190058
commit d3c3c6d90a
3 changed files with 30 additions and 5 deletions

View file

@ -5,6 +5,7 @@
Title="Sample App" Height="500" Width="625">
<Grid>
<Grid.Resources>
<local:NullToCollapsedConverter x:Key="nullConv" />
<Style TargetType="UserControl" x:Key="card">
<Setter Property="Margin" Value="10" />
<Setter Property="Padding" Value="10" />
@ -21,11 +22,11 @@
<TabItem Header="GPS Info">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" Background="#FFEEEEEE">
<WrapPanel>
<local:GprmcControl x:Name="gprmcView" Style="{StaticResource card}" />
<local:GpggaControl x:Name="gpggaView" Style="{StaticResource card}" />
<local:GpgsaControl x:Name="gpgsaView" Style="{StaticResource card}" />
<local:GpgllControl x:Name="gpgllView" Style="{StaticResource card}" />
<local:PgrmeControl x:Name="pgrmeView" Style="{StaticResource card}" />
<local:GprmcControl x:Name="gprmcView" Style="{StaticResource card}" Visibility="{Binding Message, ElementName=gprmcView, Converter={StaticResource nullConv}}" />
<local:GpggaControl x:Name="gpggaView" Style="{StaticResource card}" Visibility="{Binding Message, ElementName=gpggaView, Converter={StaticResource nullConv}}" />
<local:GpgsaControl x:Name="gpgsaView" Style="{StaticResource card}" Visibility="{Binding Message, ElementName=gpgsaView, Converter={StaticResource nullConv}}" />
<local:GpgllControl x:Name="gpgllView" Style="{StaticResource card}" Visibility="{Binding Message, ElementName=gpgllView, Converter={StaticResource nullConv}}" />
<local:PgrmeControl x:Name="pgrmeView" Style="{StaticResource card}" Visibility="{Binding Message, ElementName=pgrmeView, Converter={StaticResource nullConv}}" />
</WrapPanel>
</ScrollViewer>
</TabItem>

View file

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace SampleApp.WinDesktop
{
public sealed class NullToCollapsedConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (value == null) ? Visibility.Collapsed : Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View file

@ -65,6 +65,7 @@
<Compile Include="KeyValuePairControl.xaml.cs">
<DependentUpon>KeyValuePairControl.xaml</DependentUpon>
</Compile>
<Compile Include="NullToCollapsedConverter.cs" />
<Compile Include="PgrmeControl.xaml.cs">
<DependentUpon>PgrmeControl.xaml</DependentUpon>
</Compile>