« first day (952 days earlier)      last day (3197 days later) » 
06:00 - 19:0019:00 - 00:00

7:00 PM
so im under the impression now that Validation.HasError refers only to the UIElement that is using it as an attached property
and not any control anyplace
 
77
Q: Detecting WPF Validation Errors

Kevin BerridgeIn WPF you can setup validation based on errors thrown in your Data Layer during Data Binding using the ExceptionValidationRule or DataErrorValidationRule. Suppose you had a bunch of controls set up this way and you had a Save button. When the user clicks the Save button, you need to make sure ...

that looks pretty nice
 
that's where I was 10 minutes ago... the problem is I don't know where to get the DependencyProperties it wants
 
it wants the main UI control
that holds all the controls to be validated
 
so the Grid on my main window
 
wouldnt it be the root control in your tab item?
 
7:04 PM
it could be the tab control yeah
either one I suppose
 
well the difference would be validating your entire window or the tab control or a tab item
 
I need to think about this a minute.... Im not sure how I would get my VM the TabControl
or if I even like that idea
It feels like this is going to be bad in terms of performance
ugh
the second answer in that linked question seems to be what I would have to do
iterate over everything and validate that there are no validation errors
and there are so many controls
that could get hairy
I think im going to try setting the validation scope
like Johan suggested
 
does each of your controls have its own backing vm?
 
each of the tabs are a UserControl with their own VM yes
 
no, each textbox that holds a setting
 
7:09 PM
no
they are just normal textboxes and whatnot
bound to the data context of the UserControl type they are part of
 
if they did each have a backing VM, this becomes way easier
 
a VM for each text field?
that's insane
 
it makes what you are trying to do easier
you could have a list of the VM's
and each VM could have a "HasError" property
then your save button is just Vms.Any(x => x.HasError)
it even lets you find out more easily which control is erroring
 
actually...
I might be half way there
I implemented a class called ValueField<T>
that has a Value and Chagned property
to facilitate highlighting changed fields
that might actually implement INPC
and serve as the VM
 
this goes back to what I'm sure I have mentioend before, that any control that goes beyong super simple operators should have its own backing VM
because it makes random stuff like this way easier!
sure, you might have hundreds or thousands of VM
but performance wise, that will be negligible
and it makes coding waaay easier
 
7:13 PM
so I lied.... each of my controls are bound to this type:


    public class ValueField<T> : AChangeReportingViewModel, INotifyPropertyChanged
    {
        private T _OriginalVal;
        public T OriginalVal
        {
            get
            {
                return _OriginalVal;
            }
            set
            {
                _OriginalVal = value;
                Value = value;
                Changed = false;
                PropertyChanged(this, new PropertyChangedEventArgs("OriginalVal"));
I could see adding a HasError there...
 
@MarkW I'll post the code when it works
 
somehow rigging up the Validation to that property
 
the hard part is done then
just bind Validation.HasError against your ValueFIeld Vm
 
Ill hold out for Johan
see what hes brewing
but that does seem viable
 
if you stored the name of the setting in that VM, you'd be able to display detailed error messages
you could even extend it to store the actual error :)
 
7:28 PM
is it possible to define an event delegate that is parameterized with a generic type?
like
delegate void Statechanged(List<?> ChangedValues);
or similar
 
7:52 PM
wow.... binding the result of validation to a vM is no easy task
evidently its read only and you cant just bind it, you gotta make an attached property
and do a lot of shit I don't understand to make it work
brutal
 
really?
hm
 
yeah...
its not just simple binding
 
 
1 hour later…
9:04 PM
@MarkW @Julien @Brad @All ^
WIP/POC (FOSS)
 
ill grab that here quick
when I figure out how to do it :P
 
git clone
 
woah a lot to wrap my head around here
 
yeah, it got a little huge when written to be leak free
usage is pretty simple
 
so if I understand this correctly, you set up the ValidationExt IsValidationScope = true on the parent control
then those classes add the children and handle the framework validation events
 
9:15 PM
yeah, you can set it on mainwindow
 
to put that up to the Validation.HasError to the stackpanel
 
then all grids etc will be scopes
 
wow
way to go beyond the call of duty there
 
@MarkW it is ValidationExt.HasError
I did not expose a property with a merged list of all errors but it is trivial to add
 
can I identify which control the error came from?
 
9:17 PM
yeah
It was strange, worked the first time I ran it
expected some pain
 
lol when that happens to me, I tend to think the worst
im going to try it here quick in my app
you gunna put this someplace as a quick little api deal for people?
maybe a nuget
 
maybe, we can test it some first
I can refactor it so that it is in a separate project hold on
 
just a suggestion, this works for me
setting it up now
 
then it is easy for you to use it and keep updated
@MarkW I don't want to post it on nuget if it is buggy and dumb
We can beta it for a while
I'll nag everyone here like crazy as usual :)
 
hehe ill be more than happy to help
seeing as how its helping me out
where is the annotation NotifyPropertyChangedInvocator defined?
nvm found it
woah
how did you get it in the properties list
lol never seen that before
how do I do this:

<Trigger Property="ValidationExt.HasError" Value="true">
<Setter Property="MenuItem.IsEnabled" Value="false"/>
</Trigger>
it says ValidationExt.HasError is not supported
bah im an idiot
got it
question.... does the ValidationExt recursively add child controls all the way down to the leaf children of the heirachy?
or just children of the control itself
 
9:43 PM
@MarkW Gu.Wpf.Validationit (pull)
@MarkW yeah, through dependency property inheritance
renamed it when I refactored
@Reed have a look if you have time
@MarkW added a sample for that
 
my only problem with that
is that it puts validation as a view concern
when it's really a VM concern
and it's bypassing normal WPF validation entirely ;)
but validation (IMO) should be a concern handled in and by the VM
 
@ReedCopsey how do you mean?
 
that really belongs in the VM, not in the View
from a separation of concerns POV
 
yeah, valid point
still standard wpf validation though
having it like that is untestable so not very nice
at least unnecessary hard to test
and validation is def things that should have tests
 
9:59 PM
how is that standard validation? You're not using any of the built in support
just doing your own validator and your own style, right?
 
no, Binding has a ValidationRules proeprty
just wrote a dummyrule that I named MehRule : ValidationRule
 
ahh,okay - yeah, I see
 
there are three standard ways to validate in wpf as I know, {exception, IDataErrorInfo, ValidationRules}
 
INotifyDataErrorInfo too ;)
 
which one do you use?
 
10:01 PM
INotifyDataErrorInfo (or IDataErrorInfo), since they're really the only ones that work in the VM
FSharp.ViewMOdule uses INotifyDataErrorInfo
 
ok, I'll update the sample with it then
never used it INotifyDataErrorInfo really
 
10:13 PM
it's a pain ;)
 
too stringy for a friday
 
10:38 PM
yo
I tried out the code in my app before I left work... I couldn't make it work. it built and executed ok, but I think Im missing part of the setup
ill play around more this weekend
see if I can wrap my head around it better
 
could be bugs, not tested much
 
maybe
but I appreciate the effort none the less
 
did you pull the latest?
 
no I just got home
literally just sat down
im going to build a simplified version of my app at home this weekend to test against
 
that is always a good thing
 
10:42 PM
pretty much a menu item on a form with a tab control
where the tab control has a custom user control with child user controls like text boxes and stuff with validation rules
that and I need to learn how to use the GitDesktop thing
get on the git train!
I wonder about Reeds comment about validation being a VM concern... and not a view... I would have thought that with respect to MVVM its a concern for the framework... given how you implement Validation rules and stuff. My VM shouldn't be concerned with casting and validating values right? it should be accepting values of a given type... and getting the data in an acceptable type would happen upstream from that
like I have a property of type int, that a view binds to on a text box... shouldn't the view/framework ensure that the value is an int before it gets to my VM?
I suppose if you take the perspective that the VM serves as the translator between the underlying model and the view, then yeah it should happen there....
just kinda confusing considering that ValidationRules are defined on the view side (not the class, but where they are implemented and when they execute)
 
@MarkW A matter of taste imo. The best argument I can think of for putting validation in vm is that it easier to test it
You still have to remember to add stuff to the binding though
 
that and validation doesn't need to be reimplemented if you change your GUI
 
oh, sure
 
but frankly I find the 'change your gui in the future' argument for MVVM advocates weak at best
 
I rarely change guis :)
 
10:53 PM
@MarkW I'd agree with type issues, but rules like "This field can't begin with an 'S'" are definitely logic rules, and should be in VM
 
the only place ive ever seen MVVM is in WPF, I know its elsewhere... but all the INPC and other interfaces that you have to implement in your VM pretty much guarantees youre gunna be using WPF with those VM's
 
@MarkW Well, WPF, or Windows Universal, or Xamarin Forms...
but not much else ;) going to be xaml based, most likely, though
 
yeah, im not sure how I feel about tech like Xamarin
it sounds great and in terms of level of effort, is pretty sweet
but... im not sold on the idea completely yet
not that I wouldn't love a code once solution for multiplatform applications
just a skeptic at heart
 
I don't see it as a code once solution
as much as a code 1.5-2x for 3 platforms solution
and code-in-your-language-of-choice solution ;)
[which, tbh, is the biggest thing - though slightly less important now that swift exists, but swift is still... not quite there]
 
lol so it has no advantages over say... the java type approach, whereas you build a language ontop of a VM, and hope that the native code strictly adheres to the language spec
cuz then its technically as you put it... 'code 1.5-2x for 3 platforms'
well I would argue that the idea that you can 'take advantage of a platforms specific feature set' means you don't really want a platform independent product
 
11:01 PM
more than you end up needing some customization for each platform
to take advantage of that platforms' specific feature set
so you end up having some custom stuff mixed in
but can share a lot of underlying tech
 
damnit
I edited that
lol
well I would argue that the idea that you can 'take advantage of a platforms specific feature set' means you don't really want a platform independent product
 
hahaha
hence my "1.5-2x" comment ;)
 
lol
 
if you really don't care about platform specific, then it's pretty damn good at reuse
but the feature set is pretty damn limiting :p
 
we should get on the Marxism train, and convert all non believers to .NET
death to the unix heathens!
 
11:05 PM
there's nothing wrong with unix ;) .net works well there, too
 
well im gunna build that app for testing.. then im gunna restring my guitar, cuz I just broke my G string
lame
lol have a good night guys
 
I wouldn't go around telling people you broke your G string ;)
 
lol
 
just a suggestion ;)
 
11:06 PM
lol pretty good
 
it is 2015, crossdressing should be fine
 
well, nothing against crossdressing, but if it's tight enough to be breaking.... I do have a problem with that :p
 
06:00 - 19:0019:00 - 00:00

« first day (952 days earlier)      last day (3197 days later) »