Click here to Skip to main content
15,880,392 members
Home / Discussions / WPF


GeneralRe: Custom Control Style Question Pin
Kevin Marois15-Sep-23 5:33
professionalKevin Marois15-Sep-23 5:33 
GeneralRe: Custom Control Style Question Pin
Gerry Schmitz15-Sep-23 5:58
mveGerry Schmitz15-Sep-23 5:58 
GeneralRe: Custom Control Style Question Pin
Kevin Marois15-Sep-23 14:54
professionalKevin Marois15-Sep-23 14:54 
Question.Net Core System.Windows.Data Namespace Pin
Kevin Marois6-Sep-23 17:51
professionalKevin Marois6-Sep-23 17:51 
AnswerRe: .Net Core System.Windows.Data Namespace Pin
Richard Deeming6-Sep-23 21:19
mveRichard Deeming6-Sep-23 21:19 
QuestionLinux - Make an overlay or something like this... Pin
Alex 5326-Aug-23 23:02
Alex 5326-Aug-23 23:02 
QuestionNavigationControl - Still Have A Problem Pin
Kevin Marois25-Aug-23 11:30
professionalKevin Marois25-Aug-23 11:30 
Question[Solved/Workaround] Floating progress visualization with button control Pin
Evilfish20009-Aug-23 23:28
Evilfish20009-Aug-23 23:28 
I have created a progress unit control that show a progress in my WPF application and it looks like this:

The way I have done this is adding a ListView in my main application view that has a higher ZIndex than the other controls. This essentially overlays all controls, but does not react hit tests and is not visible.
<ListView x:Name="ProgressListView" Grid.Row="1" Grid.RowSpan="2" ItemsSource="{Binding ProgressCollection}" Background="Transparent" Panel.ZIndex="10" IsHitTestVisible="False">
<!-- Omitted WPF for the progress units -->
I have most of the WPF code here, but if you need it, I can post it

This works as you can see from the picture. If you look at the picture, there is a close image which is implemented this way:
<Button Grid.Row="0" Grid.Column="1" 
Content="{wpf:MaterialIconExt Kind=WindowClose}"
Command="{Binding CloseProgressCommand}" 
Style="{StaticResource ProgressButtonStyle}" />

I would like to be able to click this button to close any progress unit, in case it blocks the users view of any controls beneath it. With my current implementation this is not possible as my ListView currently is marked with IsHitTestVisible="False". That means all controls under it also ignores the hit test, even if I set the buttons IsHitTestVisible to true. That means the button cannot be clicked by the mouse.

How can I make the button work on my progress unit and still have them floating?

So far:
  • I have experimented with overriding the hittest of the listview, so I can ignore hittest in code but allow the button to be pressed. This did not work, but I am still looking into this.
  • I have tried fiddling with the ZIndex on the Button, but if the listview ZIndex is lower that the rest, then buttons inside it will of cause also be behind it, no matter the buttons ZIndex. Its a part of the ListView.
  • I have also looked into the Adorner layer. I find that this could probably work, but it will require a complete rewrite of the logic and as I understand it is not really what it is meant for and will be very complicated.
Any suggestions is very welcome. I am 99% done, I just need the last little piece of the puzzle.

So browsing some more and looking a bit into the links in the replies, I came up with a solution. I found it while browsing but to be honest i forgot where from. Anyway, the first thing i did was taking a part of @Gerry Schmitz advice and remove the z indexs. Then wil browsing @Richards supplied links for the n'th time i came a cross the workaround/solution.

I added a canvas as the first item and moved listview control in there. The canvas was then set to align content to the bottom and then i anchored the listview to the bottom of the canvas. Code looks like this:
<Canvas Grid.Row="1" Grid.RowSpan="2" VerticalAlignment="Bottom">
    <ListView x:Name="ProgressListView" ItemsSource="{Binding ProgressCollection}" Background="Transparent" Canvas.Bottom="0" BorderThickness="0">
    <!-- Content -->

This produces some what the result i was expecting. The progress controls is now fully responsive as I am no longer disabling the hittest. And the controls underneath the canvas is responding to mouse events. The reason this works is that the listview control is almost hidden when no progresses are shown. I tiny fraction of the ui in the corner is where the listview is. I could probably enable and disable the hittest in those conditions, but for now i think it is fine.

The reason i am calling this a work around is that when progresses are shown, ei more that 1, the space between the progress controls is not really a space and the mouse event does not sip through to the underlying controls. But we are also talking about 3-4 pixels in width, so only if a user is trying to click between something that is blocking for 5 seconds, then this becomes a problem. I think this will work for now. I still have some styling to do, but the close button now works as expected.

modified 11-Aug-23 4:01am.

AnswerRe: Floating progress visualization with button control Pin
Richard Deeming10-Aug-23 0:26
mveRichard Deeming10-Aug-23 0:26 
GeneralRe: Floating progress visualization with button control Pin
Evilfish200010-Aug-23 0:47
Evilfish200010-Aug-23 0:47 
AnswerRe: Floating progress visualization with button control Pin
Gerry Schmitz10-Aug-23 6:11
mveGerry Schmitz10-Aug-23 6:11 
QuestionWPF EF Core 6 DP Question Pin
Kevin Marois24-Jul-23 14:42
professionalKevin Marois24-Jul-23 14:42 
AnswerRe: WPF EF Core 6 DP Question Pin
Richard Deeming24-Jul-23 21:36
mveRichard Deeming24-Jul-23 21:36 
GeneralRe: WPF EF Core 6 DP Question Pin
Kevin Marois25-Jul-23 8:10
professionalKevin Marois25-Jul-23 8:10 
GeneralRe: WPF EF Core 6 DP Question Pin
Richard Deeming25-Jul-23 21:41
mveRichard Deeming25-Jul-23 21:41 
GeneralRe: WPF EF Core 6 DP Question Pin
Kevin Marois27-Jul-23 19:27
professionalKevin Marois27-Jul-23 19:27 
GeneralRe: WPF EF Core 6 DP Question Pin
Richard Deeming30-Jul-23 21:55
mveRichard Deeming30-Jul-23 21:55 
QuestionWPF xceed CheckcComboBox SelectAll Text Pin
Kevin Marois20-Jun-23 18:17
professionalKevin Marois20-Jun-23 18:17 
AnswerRe: WPF xceed CheckcComboBox SelectAll Text Pin
Richard Deeming20-Jun-23 20:53
mveRichard Deeming20-Jun-23 20:53 
GeneralRe: WPF xceed CheckcComboBox SelectAll Text Pin
Kevin Marois21-Jun-23 10:32
professionalKevin Marois21-Jun-23 10:32 
QuestionList of Images Pin
Kevin Marois9-Jun-23 13:47
professionalKevin Marois9-Jun-23 13:47 
QuestionChange Image URL's Assembly At Runtime Pin
Kevin Marois6-Jun-23 7:15
professionalKevin Marois6-Jun-23 7:15 
AnswerRe: Change Image URL's Assembly At Runtime Pin
Gerry Schmitz6-Jun-23 15:52
mveGerry Schmitz6-Jun-23 15:52 
Questionc# Spotify API not returning correctly. Pin
elfenliedtopfan52-Jun-23 18:03
elfenliedtopfan52-Jun-23 18:03 
AnswerRe: c# Spotify API not returning correctly. Pin
Pete O'Hanlon4-Jun-23 8:42
mvePete O'Hanlon4-Jun-23 8:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.