Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Clean up styling in Silverlight demo

  • Loading branch information...
commit 1ff159369baea4760eb6ec4f8c8e76d20a43557a 1 parent fb925cc
@jschementi authored
View
19 Schementi.Controls.Demos.Sparkline.Silverlight/HeightToFontSizeConverter.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Globalization;
+using System.Windows;
+using SystemConvert = System.Convert;
+using System.Windows.Data;
+
+namespace Schementi.Controls.Demos.Sparkline.Silverlight {
+ public class HeightToFontSizeConverter : IValueConverter {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
+ var intValue = SystemConvert.ToDouble(value);
+ if (intValue <= 0) return DependencyProperty.UnsetValue;
+ return intValue;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
+ return Convert(value, targetType, parameter, culture);
+ }
+ }
+}
View
9 Schementi.Controls.Demos.Sparkline.Silverlight/MainPage.xaml
@@ -4,10 +4,15 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:schementi="clr-namespace:Schementi.Controls;assembly=Schementi.Controls.Sparkline"
- xmlns:sdk="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
+ xmlns:sdk="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
+ xmlns:local="clr-namespace:Schementi.Controls.Demos.Sparkline.Silverlight"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
+ <UserControl.Resources>
+ <local:HeightToFontSizeConverter x:Name="HeightToFontSizeConverter" />
+ </UserControl.Resources>
+
<Grid Background="Black" x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition/>
@@ -26,7 +31,7 @@
<RowDefinition/>
</Grid.RowDefinitions>
<Rectangle Fill="#22FFFFFF"/>
- <TextBlock Text="sell orders" FontSize="{Binding ActualHeight, ElementName=HeightElement}" Foreground="#DDFFFFFF" HorizontalAlignment="Left" VerticalAlignment="Center" />
+ <TextBlock Text="sell orders" FontSize="{Binding ActualHeight, ElementName=HeightElement, Converter={StaticResource HeightToFontSizeConverter}}" Foreground="#DDFFFFFF" HorizontalAlignment="Left" VerticalAlignment="Center" />
<Grid VerticalAlignment="Stretch" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
View
1  Schementi.Controls.Demos.Sparkline.Silverlight/Schementi.Controls.Demos.Sparkline.Silverlight.csproj
@@ -80,6 +80,7 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
+ <Compile Include="HeightToFontSizeConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
View
13 Schementi.Controls.Demos.Sparkline/MainPage.xaml.cs
@@ -25,6 +25,15 @@
namespace Schementi.Controls.Demos.Sparkline {
public partial class MainPage {
+
+ private const bool IsSilverlight =
+#if SILVERLIGHT
+ true
+#else
+ false
+#endif
+ ;
+
static readonly object StopLock = new object();
public MainPage() {
InitializeComponent();
@@ -111,8 +120,8 @@ public partial class MainPage {
Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x55, 0x55, 0x55)),
BorderBrush = new SolidColorBrush(Colors.Gray),
BorderThickness = new Thickness(0.4),
- Padding = new Thickness(0.4),
- Margin = new Thickness(0, 0, 0, 1),
+ Padding = new Thickness(0.4, IsSilverlight ? 0.4 : 0.0, 0.4, IsSilverlight ? 0.0 : 0.4),
+ Margin = new Thickness(0, 0, 0, 0.5),
VerticalAlignment = VerticalAlignment.Bottom,
RenderTransform = new ScaleTransform { ScaleY = -1.0 },
RenderTransformOrigin = new Point(0.5, 0.5),
View
2  Schementi.Controls.Sparkline/Sparkline.xaml
@@ -7,7 +7,7 @@
mc:Ignorable="d"
d:DesignHeight="100" d:DesignWidth="300">
<Grid x:Name="Root" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="1">
- <ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled" x:Name="ScrollViewer" Padding="0">
+ <ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled" x:Name="ScrollViewer" Padding="0" BorderThickness="0">
<Viewbox HorizontalAlignment="Left" VerticalAlignment="Stretch" Stretch="Uniform" StretchDirection="Both">
<Grid x:Name="Canvas" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
Please sign in to comment.
Something went wrong with that request. Please try again.