I've been playing around with c# and WPF for about 3 weeks now trying to create a plugin to get things done faster in Revit. I've solved most problems by myself, but this one I could really do with some help. So I have this WPF window that will have a few tabs, one to select things, others to set settings and print, etc. The default window size works for my example file, but when I resize it, the DataGrid does not resize with the table, and If I make the window smaller the status bar will disappear. Also, the DataGrid could do with scrollbars.
<Window x:Class="BDS.JustPrintMainWindow"
xmlns=";
xmlns:x=";
xmlns:d=";
xmlns:mc=";
xmlns:local="clr-namespace:BDS"
mc:Ignorable="d"
Title="Just Print" Height="388" Width="878">
<DockPanel>
<TabControl DockPanel.Dock="Top">
<TabItem Header="Select Sheets/Views" Margin="-2,0,-2,-2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<WrapPanel Grid.Row="0">
<RadioButton Margin="5,5,5,5" IsChecked="True">
Views
</RadioButton>
<RadioButton Margin="5,5,5,5">
Sheets
</RadioButton>
</WrapPanel>
<DataGrid Name="uiViewDisplay" Grid.Row="1" SelectionUnit="FullRow" SelectionMode="Extended" Loaded="OnGridLoad">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Select">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=DataGridRow}, Mode=TwoWay}" IsHitTestVisible="False"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</TabItem>
<TabItem Header="Print Settings" Margin="-2,0,-2,-2">
</TabItem>
</TabControl>
<StatusBar DockPanel.Dock="Bottom" Height="20" VerticalAlignment="Bottom">
<StatusBar.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</StatusBar.ItemsPanel>
<StatusBarItem Grid.Column="0">
<TextBlock>Sheets Selected</TextBlock>
</StatusBarItem>
<Separator Grid.Column="1"/>
<StatusBarItem Grid.Column="2">
<TextBlock>Views Selected</TextBlock>
</StatusBarItem>
<Separator Grid.Column="3"/>
<StatusBarItem Grid.Column="4">
<ProgressBar Value="70" Width="90" Height="20"/>
</StatusBarItem>
</StatusBar>
</DockPanel>
</Window>
This is like the default opening position, which is almost perfect
And when I shrink the window, status bar has disappeared - and the data grid could do with scroll bars.
Thanks for any suggestions.
I've been playing around with c# and WPF for about 3 weeks now trying to create a plugin to get things done faster in Revit. I've solved most problems by myself, but this one I could really do with some help. So I have this WPF window that will have a few tabs, one to select things, others to set settings and print, etc. The default window size works for my example file, but when I resize it, the DataGrid does not resize with the table, and If I make the window smaller the status bar will disappear. Also, the DataGrid could do with scrollbars.
<Window x:Class="BDS.JustPrintMainWindow"
xmlns="http://schemas.microsoft/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats./markup-compatibility/2006"
xmlns:local="clr-namespace:BDS"
mc:Ignorable="d"
Title="Just Print" Height="388" Width="878">
<DockPanel>
<TabControl DockPanel.Dock="Top">
<TabItem Header="Select Sheets/Views" Margin="-2,0,-2,-2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<WrapPanel Grid.Row="0">
<RadioButton Margin="5,5,5,5" IsChecked="True">
Views
</RadioButton>
<RadioButton Margin="5,5,5,5">
Sheets
</RadioButton>
</WrapPanel>
<DataGrid Name="uiViewDisplay" Grid.Row="1" SelectionUnit="FullRow" SelectionMode="Extended" Loaded="OnGridLoad">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Select">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=DataGridRow}, Mode=TwoWay}" IsHitTestVisible="False"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</TabItem>
<TabItem Header="Print Settings" Margin="-2,0,-2,-2">
</TabItem>
</TabControl>
<StatusBar DockPanel.Dock="Bottom" Height="20" VerticalAlignment="Bottom">
<StatusBar.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</StatusBar.ItemsPanel>
<StatusBarItem Grid.Column="0">
<TextBlock>Sheets Selected</TextBlock>
</StatusBarItem>
<Separator Grid.Column="1"/>
<StatusBarItem Grid.Column="2">
<TextBlock>Views Selected</TextBlock>
</StatusBarItem>
<Separator Grid.Column="3"/>
<StatusBarItem Grid.Column="4">
<ProgressBar Value="70" Width="90" Height="20"/>
</StatusBarItem>
</StatusBar>
</DockPanel>
</Window>
This is like the default opening position, which is almost perfect
And when I shrink the window, status bar has disappeared - and the data grid could do with scroll bars.
Thanks for any suggestions.
Share Improve this question asked Feb 14 at 23:21 whitelinedwhitelined 3405 silver badges14 bronze badges 4 |1 Answer
Reset to default 1<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<Grid.RowDefinitions>
<DataGrid Grid.Row="0"/>
<StatusBar Grid.Row="1"/>
<Grid>
Use a Grid
instead of a DockPanel
. Then, define the Grid.Row attached property to your DataGrid and StatusBar accordingly.
If you need a powerful table that can display complex data, or support complex data operations, I suggest looking at the Data Grid made by DevExpress.
DockPanel.Dock
fromTabControl
and keep it as the last child. Read learn.microsoft/en-us/dotnet/api/… – Sir Rufo Commented Feb 15 at 4:01