Skip to content

Commit

Permalink
Fixing sizing issues of WPF User Controls inside Excel Actions Pane.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Meyrelles committed Jun 21, 2012
1 parent 994c7ee commit 7d5645b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
using ModernCashFlow.Excel2010.Forms;
using Microsoft.Office.Tools;
using ModernCashFlow.Excel2010.Forms;

namespace ModernCashFlow.Excel2010.Commands
{
public class ConfigureSidePanelCommand : ICommand
{
private readonly SidePanelWpfHost _host;
private readonly ActionsPane _sidePane;

public ConfigureSidePanelCommand()
{
_host = new SidePanelWpfHost();
Globals.ThisWorkbook.ActionsPane.Controls.Add(_host);
_sidePane = Globals.ThisWorkbook.ActionsPane;
_sidePane.Controls.Add(_host);

//solicitar o refresh do host do wpf sempre que o panel mudar de tamanho ou acontecer algum scroll.
Globals.ThisWorkbook.ActionsPane.Resize += delegate { _host.Refresh(); };
Globals.ThisWorkbook.ActionsPane.Scroll += delegate { _host.Refresh(); };
_sidePane.Resize += delegate { _host.Refresh();
_host.Height = _sidePane.Height;
};

_sidePane.Scroll += delegate { _host.Refresh(); };

}
public void Execute(CommandArgs args)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ public partial class SidePanelWpfHost : UserControl
public SidePanelWpfHost()
{
InitializeComponent();
this.SizeChanged += new EventHandler(SidePanelWpfHost_SizeChanged);
}

void SidePanelWpfHost_SizeChanged(object sender, EventArgs e)
{
if (this.CurrentControl != null)
{
CurrentControl.Height = this.Height;
}
}

public dynamic Model
Expand Down
7 changes: 2 additions & 5 deletions Solution2010/ModernCashFlow.WpfControls/SaidaInspector.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:SampleData="clr-namespace:Expression.Blend.SampleData.SampleDataSource" x:Class="ModernCashFlow.WpfControls.SaidaInspector"
mc:Ignorable="d"
d:DesignHeight="440" d:DesignWidth="300" Height="700">
d:DesignHeight="440" d:DesignWidth="300">
<UserControl.Resources>
<SampleData:SampleDataSource x:Key="SampleDataSource" d:IsDataSource="True"/>
</UserControl.Resources>
Expand All @@ -20,10 +20,7 @@
<GradientStop Color="White"/>
</LinearGradientBrush>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="60" x:Name="Header" />
<RowDefinition Height="*" x:Name="MainContent" />
</Grid.RowDefinitions>
Expand Down

0 comments on commit 7d5645b

Please sign in to comment.