Advertisement
Guest User

Untitled

a guest
Mar 28th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. <Window x:Class="WpfTest.MainWindow"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:local="clr-namespace:WpfTest"
  5. Title="MainWindow" Height="600" Width="800">
  6. <Window.Resources>
  7. <local:HalfValueConverter x:Key="halfConv" />
  8.  
  9. <Style TargetType="Line">
  10. <Setter Property="Stroke" Value="Red"/>
  11. <Setter Property="StrokeThickness" Value="1"/>
  12. <Setter Property="RenderOptions.EdgeMode" Value="Aliased"/>
  13. <Setter Property="SnapsToDevicePixels" Value="True" />
  14. </Style>
  15. </Window.Resources>
  16. <Grid>
  17. <Grid.RowDefinitions>
  18. <RowDefinition Height="*"/>
  19. <RowDefinition Height="Auto"/>
  20. <RowDefinition Height="*"/>
  21. </Grid.RowDefinitions>
  22. <Grid Grid.Row="2" Background="Black" Name="grdParent">
  23. <Line X1="{Binding ActualWidth, ElementName=grdParent, Converter={StaticResource halfConv}}"
  24. Y1="0"
  25. X2="{Binding ActualWidth, ElementName=grdParent, Converter={StaticResource halfConv}}"
  26. Y2="{Binding ActualHeight, RelativeSource={x:Static RelativeSource.Self}}"
  27. Height="100"
  28. />
  29. <Line X1="0"
  30. Y1="{Binding ActualHeight, ElementName=grdParent, Converter={StaticResource halfConv}}"
  31. X2="{Binding ActualWidth, RelativeSource={x:Static RelativeSource.Self}}"
  32. Y2="{Binding ActualHeight, ElementName=grdParent, Converter={StaticResource halfConv}}"
  33. Width="100"
  34. />
  35. </Grid>
  36. <GridSplitter Grid.Row="1" Height="5" HorizontalAlignment="Stretch" Background="Gray" ResizeBehavior="PreviousAndNext" ResizeDirection="Rows" />
  37. </Grid>
  38. </Window>
  39.  
  40. using System;
  41. using System.Windows.Data;
  42.  
  43. namespace WpfTest
  44. {
  45. public class HalfValueConverter : IValueConverter
  46. {
  47. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  48. {
  49. return ((double)value / 2);
  50. }
  51.  
  52. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  53. {
  54. return ((double)value * 2);
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement