Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
WPF DynamicGrid python and XAML layout files
  • Loading branch information
denfromufa authored and den-run-ai committed Mar 23, 2016
commit ef51247412dcd37f223bcb66d7d505fad12f9c5d
23 changes: 23 additions & 0 deletions demo/DynamicGrid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import clr
import sys
if sys.platform.lower() not in ['cli','win32']:
print("only windows is supported for wpf")
clr.AddReference(r"wpf\PresentationFramework")
from System.IO import StreamReader
from System.Windows.Markup import XamlReader
from System.Threading import Thread, ThreadStart, ApartmentState
from System.Windows import Application, Window


class MyWindow(Window):
def __init__(self):
stream = StreamReader("DynamicGrid.xaml")
window = XamlReader.Load(stream.BaseStream)
Application().Run(window)


if __name__ == '__main__':
thread = Thread(ThreadStart(MyWindow))
thread.SetApartmentState(ApartmentState.STA)
thread.Start()
thread.Join()
34 changes: 34 additions & 0 deletions demo/DynamicGrid.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WpfApplication1" Height="300" Width="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Content="Left" Grid.Column="0" Background="LightBlue" />
<GridSplitter
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Grid.Column="1"
Width="5"
Grid.RowSpan="3"/>
<Label Content="Right" Grid.Column="2" Grid.Row="2" Background="LightBlue" />
<Label Content="Top" Grid.Column="2" Background="LightGreen"/>
<GridSplitter
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Grid.Row="1"
Width="Auto"
Height="5"
Grid.ColumnSpan="3"/>
<Label Content="Bottom" Grid.Column="0" Grid.Row="2" Background="LightGreen" />
</Grid>
</Window>