« first day (1221 days earlier)      last day (2928 days later) » 

8:16 AM
Morning
 
hey
 
8:49 AM
Good morning
 
9:00 AM
@franssu, how's your Yaris ?
 
great :)
didn't drive this week end though
 
:D
 
 
4 hours later…
12:54 PM
0
Q: Access Datacontext from binded user control

Zwani build dynamic usercontrol from an observablecollection cs code: public static ObservableCollection<Model.Model.ControleData> ListControleMachine = new ObservableCollection<Model.Model.ControleData>(); public Genkai(string Autorisation) { InitializeCompo...

 
 
2 hours later…
3:10 PM
posted on February 22, 2016 by ericlippert

This is a small room with passages to the east, northeast and south, and a forbidding hole leading west. Bloodstains and deep scratches (perhaps made by an axe) mar the walls. A troll, brandishing a bloody axe, blocks all passages … Continue reading →

 
4:03 PM
i have a ListBox with SelectionMode = Extended
how can i make it so ListBoxItems have a context menu only when multiple items are selected
 
maybe the ListBox needs to only have a contextmenu when multiple items are selected?
 
yes that is what i want
one issue is that i dont want the context menu on the listbox
i want it on the items
so i apply a style to to the listbox targetting ListBoxItem and setting ContextMenu
i figure i need some sort of trigger to enable/disable it
further complicated by the fact that you cant bind SelectedItems for some stupid reason
 
is it not a dependency property?
 
it's read only
 
@Julien How do you access the SelectedItems list without binding ?
 
4:15 PM
the "recommended" way is to hold a Selected bool in each itemssource item
that gets toggled via style
some people create a custom listbox with a custom dp that just copies the read only prop
 
The first one wouldn't work if ListBox is virtualized
 
why not?
maybe if you are selecting items programatically or something?
 
Yes, this approach is extremely fragile when using virtualization, you can't select / unselect items from code, you cant select and unselect items correctly even from UI when using the Recycle virtualization mode.
 
4:34 PM
@Julien If you use a solution that allows you to have a synchronized collection with the selected items in VM (a behavior maybe) disabling the context menu via ContextMenuService.IsEnabled from a trigger should be easy.
 
5:03 PM
Anyone ever had an issue where dcpromo on a new DC would render DNS useless whilst promoting itself? Its local DNS actually had no zones in it, but it still wouldn't resolve the AD zone from the main DC after it started
Actually had to hostfile
 
why would doing it from code matter
the listbox style defines that when an item is selected it toggles the bool
how does virtualization affect that
my understanding of virtualization is it only draws the items currently visible
the backing data contexts all still exist
i didnt even know ContextMenuService.IsEnabled was a thing
 
5:32 PM
Is there a way to make it so that collapsed item doesn't take a column from uniformgrid?
 
uniform grid defines an equal width column/row for each item
doubt it
i'd recommend itemscontrol
 
Well I'm using using it with itemscontrol container. I'm trying to make kinda like wrappanel where items fill the empty space. Uniform grid worked good, but if I need to hide one item it just leaves a hole in there :P
 
5:48 PM
is it a bound collection?
pretty easy just to remove the item temporarily
 
Ok i changed the approach. Now I have wrappanel and item width is binded to the container width.
 
ew :P
 
Works good
Well seems like a lot better approach than temporarily removing items from the collection
 
to each their own i guess :D
 
Well what's wrong with this :P
Simple and works exactly the same as the uniformgrid solution except that now I can collapse items.
 
5:52 PM
i dunno, probably nothing. i dont really know what you are doing. i am just biased to doing stuff via binding
seems easier to me
itemscontrol -> bound to VM -> to hide/show items, add/remove from collection
minimal view code
 
Well it's a lot less code to just bind the visibility than to remove from collection
 
you still have code somewhere that is toggling the visibility of the view item
not much different
 
Binding
 
right. i would argue that having a collection that explicitly defines what is currently visible is cleaner
List<PossibleOptions> with ObvserableCollection<PresentedOptions>
 
It changes, items have categories and user can enable/disable categories. Adding and removing items doesn't sound very smart when you can just bind to Categor.Active with a converter that converts bool to visibility.
 
5:59 PM
you have a list of items bound to an itemssource
the "correct" way to do it is to manipulate the itemssource
adding/removing is not expensive performance wise
maybe i am just talking out of my ass :D
 
6:23 PM
0
Q: ListBoxItem ContextMenu only when ListBox Multiple Items Selected

JulienHow can I disable the listboxitem context menu when none or only one item is selected? ListBox has a SelectedItems property, but it is read only and you cannot bind to it. <ListBox ItemsSource="{Binding Items}" SelectionMode="Extended"> <ListBox.ItemContainerStyle> <Style TargetTy...

 
6:35 PM
well didnt take long for someone to answer and make me feel stupid
lol
 
6:47 PM
guys
is silverlight dead can wpf be deployed to web?
how should we create rich interactive apps for the web now?
 
@Asheh Html5 is pretty much the way to go now.
Silverlight is still in use, though.
 
I want to write a tool thats shared
Between offline and web
whats my options?
 
one data layer with two ui's
 
one in wpf and one in...?
 
a web framework of some sort
too many to list
 
6:53 PM
kendo ui?
 
i suck at web stuff
back in the day i did CakePHP
 
can you share c sharp code?
asp.net
hmm
 
you are not going to be able to share any UI stuff
pretty much 0
you could certainly share a c# dll for data access though
 
7:09 PM
how?
 
have you ever made a dll before?
new project -> class library
 
ofcouse
but how does that go on the web?
 
? i think we are thinking about different things
your web project adds the dll as a reference
just like any other project that wants to use a dll
 
@Asheh If you can build all of your backend logic as a webservice, and have both the rich client app (wpf) and the web application (html/js) talk to the webservice... that would be one way.
 
data access != data source hehe
 
7:15 PM
You COULD share UI if the "rich client app" is effectively just a web browser in disguise.
 
ok. fair enough. i am so used to working from desktop land i forget that you can embed web stuff into desktop app
my company uses rocket chat that has a windows client that does exactly that
 
But then you're just talking about building a single solution (the web app), and a separate app that goes fullscreen as a web browser.
@Julien That was all one thought aimed at @Asheh
 
i know. probably a good idea too if your goal is minimal code writing
unfortunately you have to be good at web stuff. lol
 
(wasn't trying to make arguments to each of your replies :)
 
so it feels to me
 
7:17 PM
Yeah, definitely need a good web dev.
 
like i coukld write somthing with Kendo UI for web
and wpf for offline
 
are you equally skilled with both languages?
pretty sweet
 
no
 
If you do that, separate the business logic into a webservice.
 
little experience with web
more with wpf
 
7:18 PM
web stuff is hard ><
 
why]
i did it when i was like 16
lol
 
i can whip up a nice ui in WPF in a few hours
doing the same in web land would pretty much be impossible for me
 
lol yeah its not as easy
 
whats that? you want page navigation?
oh, here you go, mess with routing and ajax and javascript
 
haha
 
7:20 PM
sorry, you want the UI to refresh dynamically?
have fun making callbacks that rewrite the view
 
thats why i was considering kendo
ui
 
whats that? you want to do something that would be easy in wpf? learn a brand new web framework!!
XBAP for life
 
xbap?
 
deprecated technology that allowed running wpf apps in internet explorer
 
yeah thats what i was thinkig
lol
 
7:22 PM
it is dead
 
:(
 
honestly, if you value your time and want a good web front end but dont have web skills, get someone else to do it lol
ok i have a funny question
KILL IT WITH FIRE
 
8:30 PM
there's always silverlight
 
9:10 PM
so user can type in either a hostname or an ipv4 address... how to validate?
 
a hostname is just a string isnt it
 
we are running low on regs
should be two rows of chatter writing wpf fulltime
 
@JohanLarsson i had to abandon the listbox work you did :(
 
and one row of phone & web guys
 
it just didnt perform well enough
 
9:16 PM
ok, huge opportunities for optimizations but nontrivial
 
the listbox would render nice and fast, and scrolling was smooth
but the images dont get filled in quickly enough
just looks wonky
 
ok, the stuff can come in handy for other things
 
here is what i did that seems to work really well, other then the fact that memory usage can balloon
        public byte[] Thumbnail
        {
            get
            {
                if (_thumbnail == null)
                {
                    ThreadPool.QueueUserWorkItem(delegate
                    {
                        Thumbnail = ItemModel.GetThumbnail();
                    });
                }

                return _thumbnail;
            }
            set { _thumbnail = value; }
        }
how many bad things am i doing here? lol
my listbox loads instantly, and fills in on the fly
what is throwing me off is that some items actually have no image, so GetThumbnail returns null. and the gets for those null images get hammered constantly and monopolize the cpu
 
you could have a flag for that
 
i tried a flag and it made no difference
?? am i smoking crack
 
9:21 PM
you could have a private static readonly byte[] Empty = byte[0];
and do ` Thumbnail = ItemModel.GetThumbnail() ?? Empty;`
 
byte[0] still seems to throw errors in the output window
 
ok, yeah
 
what i'd really like to do is return DependencyProperty.UnsetValue like a converter does
 
maybe you need to read the bytes from an empty image
 
but i dont know how to tie that into the prop
yeah thats my backup plan
 
9:22 PM
doing QueueUserWorkItem in the getter is a bit special :)
 
lol
it feels so wrong but it works surprisingly well
 
what did the code using the event look like?
@Julien not a huge issue in a viewmodel imo
 
            var listBoxItem = (ListBoxItem)e.OriginalSource;

            var isScrolledIntoView = Gu.Wpf.ScrollExtensions.ListBoxItem.GetIsScrolledIntoView(listBoxItem);

            var itemVm = (IItemVm)listBoxItem.DataContext;

            if (isScrolledIntoView == Gu.Wpf.ScrollExtensions.ScrolledIntoView.Fully ||
                isScrolledIntoView == Gu.Wpf.ScrollExtensions.ScrolledIntoView.Partly)
            {
                //ThreadPool.QueueUserWorkItem(delegate
                //{
                //itemVm.GetThumbnail();
 
Would be more of a problem if you did it in a library
 
i feel like if you want your methodology to work, you have to put in some predictive logic
that loads the items around what you are currently viewing
 
9:24 PM
@Julien you could make the eventhandler async void and do:
 
like if i am looking at the 50 items, it should load images for the previous and next 50
 
itemVm.Thumbnail = await Task.Run(() => GetImage());
 
! ok i'll try that
oh one other issue i had was if you sort the items none of the events fire
even OnFirstAppearance
 
@Julien you should be able to figure out index of the item
@Julien gah, sounds like I dumbed something
though using the containergenerator would handle that but was a guess
 
yeah i guess using the index thats not too tough
more stuff to try
seems like predictive stuff gets out of hand really easily though
if i am firing hundreds of GetImage calls
is Task.Run > ThreadPool.QUeueUserWorkItem ?
my undewrstanding is threadpool is best for lots of short lived tasks
 
9:28 PM
@Julien yeah, probably maybe
tasks has pretty low overhead since 4.5 iirc
how do you load the images btw? from file?
If you load them from file you should use stream and the async API, pretty sure it will be best perf
very little cpu in loading a file, not nice to use threads for IO
 
sqlite db
which is another piece of the puzzle, i'm sure.
 
ok no idea what it offers
 
i have a table that stores only images and it seems to take longer to pull then it should, even though as long as the column is indexed table size shouldnt matter
 
prediction can probably be tricky if users scroll fast
 
was also wondering if i should be grouping sql calls
 
9:34 PM
there is a deferred scrolling thing that may be right
never used it
I don't know any db but think you want chunky not chatty for perf
 
yeah and its definitely super chatty right now
maybe a listbox event that says scrolling has stopped and gives you a list of visible items
but then if you just smooth scroll the collection nothing would load
maybe the listboxitem appearing event should be row based, somehow
so many options
 
10:07 PM
go with what you have if it works good enough
you could perhaps use the event to set the arrays to null when they scroll out idk
 
10:17 PM
itemVm.Thumbnail = await Task.Run(() => itemVm.GetThumbnail());
does not compile
is thumbnail supposed to be set inside the task?
 
is the method async?
 
private async void ScrolledIntoViewChanged_OnHandler(object sender, RoutedEventArgs e)
cant convert void to byte[]
 
what is the signature of GetThumbnail()?
 
oh. lol. void
it sets the property internally
 
await Task.Run(() => itemVm.GetThumbnail());
then
 
10:21 PM
my example earlier was simplified. right
ok my noobness is showing here
but if you put await, doesnt it make it wait for result
which is what i dont want?
 
it does not block
 
ah. ooook
 
but I guess you can fire/forget it
 
wait != block
 
task.Wait() is blocking
await is not
async void is not very nice though
 
10:23 PM
yeah i have actually run into that causing all sorts of weird problems before
 
GetThumbNail better not throw
 
i can change it GetThumbnail to return Task right
 
but it makes no difference as the eventhandler must be async void
cleaner not to have the method do task run inside imo
then you can chose to call it sync or task run it
 
it works !!
memory usage staying low
really highlights that i should be grouping my sql calls
super slick
do you want me to put up an issue for sorting not firing events?
 
yes, would be nice
for memory, will probably be after modern :)
unless you write a pr :)
but issues are always nice
 
10:29 PM
i'll put up a sample project. i have never done a pr
i'll make it a little dynamic data demo too :D
 
sweet, reference the sample project in the issue
gonna need UI-tests for sure
 
11:04 PM
Hi people.
 
thanks
I may have solved the issue.
 
haha!
you can try DynamicData, AnimatingTilePanel and PropertyChanged.Fody in one fell swoop
 
:)
no issue?
nvm, found it
 
11:20 PM
did you resize the window? hehe i did. false alarm
 
testing it now
@Julien was there no bug?
 
the debugger should break when you sort
it doesnt
VS only, sorry
 
pushed an update, don't think it worked
must walk the dogs ow
gonna make a nuget package of it I think
pain to upgrade without
 
:D
 
If it doesn't work this is probably the bug
should add nullcheck on template also
 
11:33 PM
my whole demo? lol
it cant be that bad
 
@Julien what do you mean?
nice demo
 
the link you gave is just my repo
 
yeah, cloned it and ran it
did not break
 
did you mean to link my repo or did you mean to link some sort of bug
that is what i am asking
 
oh sry, wrong link, meant this line
 
11:44 PM
OnItemsChanged fires on a sort?
 
dunno, think so
 
none of the items are changing. but it might
i guess their index is changing
dunno how that applies
                    <DockPanel.InputBindings>
                        <MouseBinding MouseAction="RightClick" Command="{Binding CmdViewDetails}" />
does not fire if the DockPanel is a ListBoxItem that is not currently selected
boo-urns
 

« first day (1221 days earlier)      last day (2928 days later) »