Click here to Skip to main content
15,797,960 members
Home / Discussions / WPF
   

WPF

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

https://pasteboard.co/peNn9PiguyNC.png

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.
XML
<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 -->
</ListView>
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:
XML
<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.

Solution/Workaround
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:
XML
<Canvas Grid.Row="1" Grid.RowSpan="2" VerticalAlignment="Bottom">
    <ListView x:Name="ProgressListView" ItemsSource="{Binding ProgressCollection}" Background="Transparent" Canvas.Bottom="0" BorderThickness="0">
    <!-- Content -->
</ListView>
</Canvas>

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