AnswerBun.com

Custom WindowChrome [ Wpf Core 3.1; MvvmCross 7.0.0 ]

Stack Overflow Asked by ge.go on December 3, 2020

How to customize the WindowChrome class while using MvvmCross?

I’ve got this:

<WindowChrome.WindowChrome>
        <WindowChrome CaptionHeight="{x:Static SystemParameters.CaptionHeight}" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
</WindowChrome.WindowChrome>
    
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <TextBlock
        Grid.Row="0"
        Grid.Column="0"
        FontSize="32"
        Text="SOME UPPER CASE TEXT THAT WILL NEVER BE DISPLAYED" />
</Grid>

inside my MvxWindow and the WindowStyle is set to none.
The problem is that MvxWindow doesn’t seem to display anything. That means I can’t create the buttons I need either. I don’t know if MvvmCross expects every UI element to be part of a View or what else is going on. Resizing and even right-clicking the invisible border works just fine. Is there any way to do this without having to rebuild the entire WindowChrome functionality inside a View?

One Answer

I will answer this myself;
while there is little difference in creating a custom WindowChrome with MvvmCross, I'll keep this question up in the hope that it could help someone else.

Not being able to display UI elements in MvxWindow is actually no problem at all. Just create the UI in your View and set the WindowChrome.IsHitTestVisibleInChrome property to true for each element you need.
There is basically no difference between doing this within a Window or a View. You just have to keep an eye on your CaptionHeight as your WindowChrome and your UI are now in two different scripts.
It could look like this:
Inside your MvxWindow:

<WindowChrome.WindowChrome>
    <WindowChrome CaptionHeight="{x:Static SystemParameters.CaptionHeight}" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
</WindowChrome.WindowChrome>

Inside the view displayed by that window:

<Menu Height="{x:Static SystemParameters.WindowCaptionHeight}">
    <MenuItem Header="_Exit" WindowChrome.IsHitTestVisibleInChrome="True" />
</Menu>

Correct answer by ge.go on December 3, 2020

Add your own answers!

Related Questions

Zoom image using css

4  Asked on February 1, 2021 by kango

       

How to make double border lines in the UIImage with the Swift?

3  Asked on February 1, 2021 by antonio-adrian-chavez

     

File Transfer Protocol using TCP

1  Asked on February 1, 2021 by thedafferg

       

Public API for all state tax names

1  Asked on January 31, 2021 by nitish

   

Remove event before remove DOM element everytime

1  Asked on January 31, 2021 by justanewcoder

       

lodash find returns only one result

1  Asked on January 31, 2021 by manuelbetancurt

     

api not call using dispatch

0  Asked on January 31, 2021 by codetribe

   

Reactjs using nginx not giving a 404

0  Asked on January 31, 2021 by keurig

       

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir