none
WPF Control on Spreadsheet Painted in Wrong Location on Resize RRS feed

  • Question

  • Hello all,

    For some reason I'm seeing a duplicate image painted on the screen whenever I resize a WPF control container on a spreadsheet.  For example, a duplicate image of a button control is painted after I resize an intersecting column with "Move and size with cells" selected  (see image):



    Steps to reproduce using Excel 2007 and Visual Studio 2010:

    1. Create a new Excel 2007 Workbook project with a new document

    2. Add a new WPF user control to the project containing a single button that fills the user control. So something like:

    <UserControl x:Class="ExcelWorkbook3.WPFUserControl"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                 mc:Ignorable="d" 
                 d:DesignHeight="48" d:DesignWidth="229">
        <Grid>
            <Button Content="Button" Name="button1"/>
        </Grid>
    </UserControl>
    

     

    3. After compiling, add a Winforms user control to the project.  Add a single ElementHost object with the WPF control above selected as the hosted content.  Set the Dock property of the ElementHost object to Fill

    4. After compiling again, open the workbook from solution explorer and insert the new winforms user control on Sheet1

    5. Right-click on the inserted object, click Format Object and select Move and size with cells on the Properties tab. Click OK.

    6. Compile and run the project.  If you now resize a spreadsheet column that overlaps the control you should see the duplicate image after a few attempts.  I can also see the issue in Design mode in Excel if I drag the resize handles for the control

    Any ideas on how to get around this issue??

    Many thanks,

    Rob

     

    Wednesday, January 18, 2012 2:45 AM

Answers

  • OK, I've run a few tests under Windows 7 and I'm not seeing the issue there either.  So I'll guess I'll attribute the problem to XP unless I see something in future testing.

    Regards,

    Rob

    • Proposed as answer by cjatmsModerator Tuesday, January 31, 2012 6:37 PM
    • Marked as answer by RobSau Wednesday, March 7, 2012 2:36 AM
    Tuesday, January 31, 2012 5:57 AM

All replies

  • Hi Rob,

     

    Thanks for posting in the MSDN Forum.

     

    Would you please clarify the “Move and size with cells” mean by a detailed scenario?

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Thursday, January 19, 2012 4:01 AM
    Moderator
  • Hi Tom,

    Thanks for the response.

    "Move and size with cells" is the setting on the Properties tab that I mention in step 5, accessed via Format Object.

    Please let me know if this still isn't clear!

    Rob


    Regards, Rob
    Thursday, January 19, 2012 4:32 AM
  • Hi Rob,

    I tried reproduce with Excel 2010 and Visual Studio 2010 on my side due to I didn't install Excel 2007 on my side. I wasn't able to reproduce your issue. I will try to reproduce your issue again next Monday. Sorry for any inconvenience.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Friday, January 20, 2012 12:29 PM
    Moderator
  • Hi Rob,

    I still can't reproduce your issue under Win7 x86, Visual Studio 2010, Office 2007. I will involve some experts into this issue to see whether they can help you. There might be some time delay. Appreciate your patience.

    Have a good day,

    Tom

     


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, January 24, 2012 9:33 AM
    Moderator
  • Hi Tom,

    Thanks for the update. FYI, I'm running XP Pro x64 with SP 2.

    Rob


    Regards, Rob
    Wednesday, January 25, 2012 5:27 AM
  • Hi Rob,

    My experience is like Tom’s.  I do not see the issue whether in debug mode or in design mode.I did not see the issue when in debug mode I grabbed the handles of the Host Element and resized it.

    Like Tom, I work on 64-bit Windows 7 using Visual Studio 2010.

    I know from overhearing the experiences of others, WPF and Office don’t share a common affinity for one-another For your project they worked well. 

    Question  – can you use a button from the Excel Common Controls  toolbox? What unique functionality do you need from the WPF button?

    Regards,
    Chris Jensen
    Senior Technical Support Lead.

     


    Chris Jensen
    Wednesday, January 25, 2012 10:20 PM
    Moderator
  • Hi Chris,

    I appreciate you looking into this.  Given the fact that you're not seeing the issue in Windows 7 and I've been using XP up to this point, I'll plan to do some testing with Windows 7 next week.

    My project requires multiple customized WPF controls.  I was using the button control as a simple example but I'm seeing the same behavior in all of my WPF controls.  Neither the Excel Form controls nor the ActiveX controls support the required UI customization unfortunately.  However, if Windows 7 works then that may be fine long term.

    I'll plan to update this thread with my results.  Thanks again for the help.

    Regards,

    Rob

    Friday, January 27, 2012 2:26 AM
  • OK, I've run a few tests under Windows 7 and I'm not seeing the issue there either.  So I'll guess I'll attribute the problem to XP unless I see something in future testing.

    Regards,

    Rob

    • Proposed as answer by cjatmsModerator Tuesday, January 31, 2012 6:37 PM
    • Marked as answer by RobSau Wednesday, March 7, 2012 2:36 AM
    Tuesday, January 31, 2012 5:57 AM