Ping function message box not working
Hi all, I am trying to use several different buttons to ping different ip's.
So far only the first 3 buttons have ip's on them using their tags
There is no error output message and it builds correctly, however, the Ping messagebox is not displaying.
Please see attached code here: https://paste.mod.gg/nnjlefslfqhc/1
BlazeBin - nnjlefslfqhc
A tool for sharing your source code with the world!
40 Replies
I don't see any instances of
PingButton_Click
in your xaml, so how are your buttons wired to your codebehind?Oh my apologies I changed all the names after pasting the code
Still wasn't generating the popuo
Popup
Btw you can self-close tags if they have no content:
<Button ..../>
instead of <Button ...></Button>
So, if the code you actually tried is different, update the code in your paste
There aren't any click handlers in your XAML@canton7 im looking at the latest bit of code you pasted in terms of how you would do it. I'm just wondering how would i apply the xaml. Does that take over my entire grid ?
Yeah, the ItemsCollection dynamically generates buttons (using that DataTemplate), and lays them out using that WrapPanel
That binding approach only really works if you're doing MVVM proper though -- it's painful if you're using the codebehind (but still do-able)
data template being this ?
PingButtons = new BindableCollection<PingButton>()
No, the
<DataTemplate>
Yeah
Would it be worth me converting my code to that now
or not really ?
Up to you
Umm well i have say 9 pages with about 5-10 of those buttons on each page
is that easier ?
Depends how much you like copy-pasting š
i don't mind if i knew exactly what i was doing
š
Time to learn!
@canton7 could I ask you for a massive flavour favour
well massive for me, maybe miniscule for you
I am struggling to understand how you converted the functions and xaml earlier.
This is my current latest version.
It also has a function of which a button will pull an image from an ip address. I've used google as an example. However thats wrong because the ip address will be the same ip address of the device above it. For example DE camera, and DE snapshot will be the sameip
whats the chances of helping me fix my code to utiilse your way and fix that function at the same time. because i believe that will help with both ping and image function
BlazeBin - trllcnnxexbr
A tool for sharing your source code with the world!
@canton7 did that explanation even make any sense
Sorry, haven't had a chance to look
all good, bud i know you are busy with your cuppa

this is a visual of what im talking about
so imagine the top row would be devices that i would use the ping function for
so there could be 5-10 of them
the bottom row i am hoping to achieve, will open an image of the camera using the same ip from the top device
in a popup window that i can close
So each "item" is two buttons, one on top of the other?
yes sir
well under each other
i have grid.row 0 = the ping function
and grid.row 1 = the snapshot function
I'd structure that as an ItemsCollection, with each item being that pair of buttons with some spacing between them
It's annoyingly hard to data-bind to grids, useful as they are
Could you help me out with that? I've really got no clue
I'm afraid I've got a chunk of work to do this afternoon
feel free to tell me to fuck off š
ok well in the interim, could you possibly just help correct my function slightly
to save your time
atm i have this
trying to get it to just take the ip from the Tag Property
Trivially, you've got the
sender
right thereI've got this
although the image didn't load
Xaml
no error message
window pops up just blank
What are you trying to do? Show a new window with the image in?
yes sir
so the window popped up correctly
the image didn't load in it
Google suggests you need to set
StreamSource
?
It'll be something to do with creating the ImageSource
Look in the Output window for cluesok
last question for the night
imagine this image
is kept behind a user/pass
in the old days i could use http:// user:[email protected] to access image
using my function i currently got, how do i implement that in c#
That's a HttpClient thing
Set the Authorization header to a new
BasicAuthenticationHeaderValue
or something IIRC?
(assuming you're using basic authentication)its weird
i can get it to pull the google image
but when i try this link it errors failed to load image
whats the reasoning behindthat
function hasn't changed at all
No idea. Use Fiddler to see what it's requesting, and a hint at why it's failing
will do
its getting late for me, i have an early flight to the mines tomorrow 4am
kinda why i was in a hurry to get it done, don't get to work on it while im away on the mines