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

6:19 AM
Morning folks!
So... who is an license expert?
 
@Markus you mean a license expert? :P
 
oh sorry
of course!
 
6:38 AM
So @Mehrad, how about you? Are you A expert? :)
 
6:49 AM
@Markus : )))) clever
sorry man. I haven't done any projects which I would use licenses :)
 
I have a problem with the AGPL license and I don't really understand it.
 
 
4 hours later…
10:28 AM
Morning clever people :)
@JohanLarsson in your Gu.Reactive documentation at github, you wrtite: "ManualRelayCommand & ManualRelayCommand" <- am I being blind or are they they same thing?
and you have the same thing right under that as "RelayCommand & RelayCommand"
i feel like that's some copy paste gone wrong
 
11:06 AM
@Markus what kinda problem? i'm no expert but there's some sites out there that can lend a hand
 
11:35 AM
@Maverik :)
 
Sir!
 
I did not spend many minutes on the documention and even less on maintaining it
 
mm, well I'm creating a program that takes certain files, and convert them into an other format. to my help I'm using a AGPL licenced program. (calling the binary, so no linking involved). Now am I alowed to do that?
 
Thanks for pointing it out
There is a demo project that demos some of the stuff
Are you gonna try it?
 
no i just randomly landed there
unfortunately no reactive/wpf coding around me for the foreseeable future
but i really like the stuff you're doing
 
11:46 AM
The nice feeling when reproducing a bug with a minimal sample.
@Maverik It is split up in one project with wpf references and one without
Both build on inpc so pretty geared towards wpf though
 
12:32 PM
yea i know, i actually did skim through your library and i like how you've laid it out
i'm sure someday i'll get to use it.. i just dont know when
right now i just wish i had your talent at designing classes :)
 
 
2 hours later…
2:09 PM
Mornin
3
Q: WPF TextBox Validation C#

user2889489I have 3 TextBoxes (Id1,Name and Salary). Id and Salary should contain integers and Name should only contain characters. I need validations for my TextBox, it should show errors as I enter wrong characters or integers. Also can this be done only in Xaml without codebehind? I'm new to Wpf and vali...

I cant seem to get the top answer to work... I implemented the contract, put a break point in, set the updatesourcetrigger to lost focus, and the method with the indexer syntax is never invoked
 
0
Q: WPF image button control

eYeLong time is now that I have been searching for a quality WPF image button control. I need the button to consist of an image only and let me set image options for hovering and pressing. All current solutions on SO and the rest of the web include CustomTemplate based solutions that are not very fr...

 
3:10 PM
@MarkW even after you have lost focus?
 
yes
Ive been looking around for a decent way to validate inputs in WPF
 
any difference with propertychanged ?
 
there seems to be a half dozen ways to do it
neither seemed to do jack
I set the properties on the text box itself
 
and is the property bound to the textbox, it's setter, getting hit?
 
yeah
 
3:11 PM
@MarkW what does this mean?
in xaml or in codebehind?
 
in XAML
gimme a sec
ill show ya
 
i just skimmed through it, seems pretty thorough.
I think i tried doing some validation, but it got to be overwhelming because i couldn't account for all the stupid things people might try to do
 
well I only really need to validate that fields for IP addresses are valid, and that numeric fields are numeric
pretty simple... or at least it should be
I can get away with PreviewTextInput for numeric input
but the IP is more complicated
heres the text box XAML
<TextBox Margin="3" Height="25" Width="175" Text="{Binding Path=IPAddress.Value, UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True}" >
 
if you look at the Asynchronous validation section. i think thats the implementation i was trying to do
bah, just use a open source IP control :)
 
and the code in the VM
public string this[string columnName]
{
get { return ValidateField(columnName); }
}
private string ValidateField(string prop)
{
string ErrorMessage = String.Empty;
switch (prop)
{
case "IPAddress":
{

try
{
System.Net.IPAddress.Parse(IPAddress.Value);
}
catch
{
ErrorMessage = "IP Address is not valid.";
}
break;
}

}
return ErrorMessage;
}
neither of those methods are ever invoked
 
3:17 PM
not sure what that indexer is supposed to do... hrmm
 
me either.... the answer had 5 up votes... figured it was worth a shot
 
because no where in XAML would it call viewModel["Name"] or in your case, yourVm["IPAddress"]
you can call in your IPAddress setter, Validate("IPAddress")
 
but then how do I make the UI not lose focus, or otherwise notify the user without injecting a UI dep in my VM
 
you could also put it in propchanged if you'd like
not sure. my instinct is that you'd have to check for Validation errors on TextChanged event
which is view-only anyways. you can't prevent someone from losing focus if the setter doesn't get called until after you already lost focus
 
im going to read that page you linked here... see if theres a more suitable option
WPF has this way of looking complicated, but then you figure out how to use something and it all gets really easy
im holding out for that here with validation
 
3:24 PM
yeah, there have a couple solutions for validation, but that comes with a learning curve. I remember @ReedCopsey F# implementation of validation was super easy.
is this all the same application you've been working on, or are you working on multiple apps? I would say next WPF application you make, use Reed's F# library
 
its another one
third WPF application
 
ahh
gotcha. just a suggestion if you find the time to be able to do it. i got pretty intimate with his FsXaml library. I really liked it. unfortunately I'm too far in to use it now
 
yeah if I had known I would be more receptive... but Ive got most of this app written now
working on input validation and some other simple logic on the forms side
custom validation rules might be the way to go
make a single one for IPValidator
and use the binding engine to invoke it
that worked...
it doesn't prevent the user from entering an invalid value, nor does it switch focus back to the device
err control
but it does highlight it red
now if I could only get the damn devices to consistently send me the complete byte sequence for the setup records..... but no.... they have to use UDP, and 1/10 times or so I wont get complete bytes
lol stupid lantronix hardware
thanks for that link Netscape
 
3:56 PM
@Maverik flatterer :)
 
I speeks only the truths!
 
4:41 PM
@MarkW i use the same :)
and I use a 3rd party OSS control
but that's for a winforms app
@Mark another, hacky solution, might be to two-way bind to IsFocused, then when set to false, validate IP is valid, if not, set IsFocused back to true. Can bind a bool to a border's visibility around the TB which is show when not valid.
though I'm thinking that might not work out the way I would expect
 
5:25 PM
why hack around stuff when you can just use ValidationRule?
they're a bit like ICommand - in that you may need quite a few of those - but they're reusable / composable rules that can plug straight into xaml
 
@Maverik custom validation rules worked out for me in the end
 
cool
 
the only part I didn't ilke was the validation rule allowing the user to switch focus
and leave the invalid value in the field
but its not the end of the world
 
there's nothing wrong with that
disabling users acccess is the old way
 
@MarkW Standard form validations should just disable form submission
 
5:29 PM
all you need to do is disable the Save button
 
not disallow switch input focus
 
that's the thing
now I gotta set all that up
 
HTML forms work the same way
 
be able to detect that any single user control has come validation error
in the entire application
 
its easy
 
5:30 PM
before the user can apply the settings
 
Command.CanExecute?
 
you have an attached property for that
 
elaborate?
 
who owns validation?
err who is it a member of
 
5:31 PM
it's an Attached Property
 
idk what you mean by that
 
mm
 
what object has the Validation object
 
its like a global property
it's affected by its context
Grid.Row for example is an attached property
 
lol
 
5:32 PM
its really grids property -- but its used in other places
 
and that's easy?
my view models don't have any user control references
 
of course it is
 
that's where all my logic is
how do I do UserControl.Validation.HasError if I don't have a reference to it
 
you have a command right?
Button -> Command scenario?
 
no
 
5:33 PM
O.O
how do you "save" ?
 
there is a menu item on the main form, which contains a number of UserControls which have their own view models.... the apply option from the menu just uses the click event to invoke a method in my VM
 
Sad Sad!
that explains why this is becoming so hard
 
yeah ive heard this lecture before
not writing a ICommand to forward an event to a VM method
 
don't..
 
not doing it no matter how much you guys say I should
 
5:35 PM
but the simple solution is Validation.HasError boolean property
pull it however you like
its a DependencyProperty btw.. so you'll need to do a GetValue on it
 
I still don't understand....
ill have to find Validation
 
yea
 
cuz if its on the UserControl type
then this is gunna suck
 
and i dont know exactly how because i normally just pass it in as a command paramter
 
because there are dozens and dozens of user controls
 
5:36 PM
no it shouldn't be on UserControl
you should be able to treat like a Static property in code
Validation is the class
 
as in verbatim: Validation.HasError
 
yes
 
what determines the context of HasError?
 
but again, its not a regular property - its an attached dependency property
 
is it any control in the app?
 
5:37 PM
thus you need DependencyProperty.GetValue bit to get boolean out of it
ValidationRule violation will cause Validation to be populated with errors
and .Count>0 will have HasError true
 
is it possible to get the specific control which has errors?
 
I'm not sure
 
to say.... select a TabItem in a TabControl that has an error
 
like i said, i've never tried it this hard way before
 
when they try to submit
 
5:38 PM
i've always had context to hand
 
how would a command help me here?
if its the same Validation class
 
pass it in as a CommandParameter
 
to what end?
 
and you'll have it in Execute as arugment
 
how does that help me locate the control with the error
 
5:39 PM
why do you need to locate control?
if you're going with disabling the control
after again pointing out that its the wrong way to do it... use Style.Triggers
 
ok... so this application has a menu, and a list, and a TabControl... the TabControl has multiple tabs for different groups of settings valus
any user control on any tab which accepts variable input could have an error
 
and DataTrigger on Validation.HasError value True
 
no maverik
lol there is a miscommunication
please.... let me explain
I would NORMALLY go with disabling the lose focus aspect of a user control to prevent users from having bad values in a control at the time of the 'submit' action
you guys think that's a bad way to do it
if I don't do it that way, now I gotta know there is an error ANYWHERE in the user input fields... which I can evidently do using Validation.HasError
but when the user clicks apply, and I detect an error
 
thats the thing, they cannot
 
simply saying "Theres an error someplace... good luck with that" isn't enough
I have to tell them where the error is cuz theres a metric shit ton of fields in this application
 
5:42 PM
ok.. - don't let them change tab?
 
that might work I suppsoe
 
you can disable whatever you want
again.. DataTrigger on HasError
and set IsEnabled to false for whatever control you fancy
(you dont need to handle inverse - it'll go back to default which is true)
you could even do something like TargetType=UIElement
and use Scoping to limit what the style applies to
but as soon as there's Validation error, disable everything via implicit style
 
yeah youre way beyond my knowledge of WPF
DataTriggers, Scoping... I went a little crossed eyed
lol
 
in that case, read how to use DataTrigger
its one of the most powerful things in xaml
 
you got a decent tutorial you would recommend?
 
5:45 PM
Binding + DataTrigger + DataTemplate -- that's all you need to know to wield most of wpf power
 
if you send me an MSDN link, ill just find my own
 
check out Reeds blog
no .. look in starred list
Reeds blog gets mentioned quite a few times - see if he has an article on triggers, if not there's plenty out there
 
i found the wpf validation to be really unintuitive and not fun to code
 
the concept is pretty simple
 
but it looks nice, so thats a plus
 
5:46 PM
i'll agree with the not fun part
 
Custom ValidationRules were super simple imho Julien
 
no but try doing stuff via IDataError -- thats a pain
 
they don't do everything
clearly...
 
but ValidationRules are definitely a big improvement
anyways, DataTriggers are like If condition of c# -- it takes a property and a value to do equality comparison on
if the result is true -- it'll do whatever you want it to do that can be done in xaml
 
Yeah, its too bad they nerfed a lot of the triggers in win store :*(
 
5:48 PM
dem nerfs men!
 
lol I feel like I should be complaining about trigger warnings
:P
 
The VSM just isn't the same
 
glad i didn't spend too much time on that!
the fact that it involved a bit of code - that kept me away from VSM
anyways, i'm gonna start my weekend early and head home
you guys have a nice evening and as always, for questions, i leave you in excellent company :)
enjoy your weeeknds and i'll see you guys monday :)
 
cya
 
Don't get me wrong, certain aspects of the VSM are cool
but I'd prefer to have the option of using triggers
 
5:55 PM
whats VSM?
Also do I have to expose Validation.HasError via a property in a VM, or is there a way to bind to that in XAML without having it as part of the datacontext
 
Visual State Manager
 
@BradleyDotNET do you know the namespace of the Validation class?
cuz the one I can find doesn't have a HasErrors property
is it GetHasError?
...
 
Looking up my example...
 
that's parameterized...
 
Hmm... mine doesn't use that
it was written by someone else though :)
haven't done a lot of validation myself
 
6:03 PM
System.Windows.Controls.Validation is the type I found
 
Here's an approach you could try though
 
and it doesn't have a HasError prop
 
Handle the validation error event and increment a counter if it was added, decrement otherwise
your can execute checks if the number of errors is currently 0
 
so, when they enter an incorrect value twice in a row, then correct it I still have an error in my counter :P
I ran into the same issue with detecting changes yesterday
might be able to work around it...
 
You check on ValidationErrorEventAction.Added
I don't think added hits if it isn't removed in the inbetween time
 
6:06 PM
that might fly
so I don't think ive ever ran into dependency properties... with maybe the exception of you helping me way back with getting a value to show up in the visual studio properties window during design time
can you help me understand what they are? cuz this Validation class needs one to know if there are errors
but I have no clue how to find what its looking for
or even if its what I need to do
 
a DP lets you add properties to a user control in design time
sort of like a xaml constructor
i dont think it has much to do with what you are trying to accomplish
 
It does a bit more than that :)
also allows for binding
 
then what is Validator.GetHasError(DependencyProperty) want?
 
Probably TextBox.TextProperty
or something similar
 
because this is sounding less and less like maveriks claim of it being "Just use a data trigger on Validator.HasError"
 
6:14 PM
Validation
not Validator
 
yeah...typeo
 
that's what I have in code
lol yeah
 
Its an attached property
so you have to type the whole thing
not just "HasError"
 
public Boolean HasErrors
{
get
{
return Validation.HasError;
}
}
does not compile
there is no Validation.HasError
 
6:15 PM
Yeah, thats not going to work
You can't access attached properties in code that way
only in XAML
 
your VM does not know what Validation is
 
then I must have fundamentally misunderstood maverik
 
your XAML has access to Validation
 
For starters, attached properties are attached to something
So to access in code you have to use a variation of GetValue
don't remember off hand :(
GetHasError is probably a wrapper around that
 
can you give me an example of a datatrigger that fires when Validation.HasError is tru?
 
6:18 PM
How about this one:
12
A: Validation.HasError attached property

kiwipomCheck out Beth Massi's article on implementing validation here Basically, you've used a DataTrigger where you just need a Trigger So: <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter ... /> </Trigger> </Style.Triggers>

Just showed up on google
not sure how accurate it is :)
 
lol
it says to use a trigger not a datatrigger
oh man...
            <MenuItem Header="Apply" Icon="{Binding Path=ApplyIcon}" Click="MenuItem_Click_1">
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="IsEnabled" Value="false"/>
                </Trigger>
            </MenuItem>
derp
 
Thats not a trigger
Ah, thats a trigger
 
C&P fail
wont build
"IsEnabled' member is not valid because it does not have a qualifying type name
 
MenuItem.IsEnabled
 
yeah that built
trying it now
bwahahaha
yeah that didn't even come close to working
it put a menu item under 'apply' called System.Windows.Trigger
 
6:24 PM
<MenuItem.Style>
<Style.Triggers>
<Trigger ... />
mm i think you need a <Style TargetType="MenuItem"> above style.triggers
 
this builds:


<MenuItem Header="Apply" Icon="{Binding Path=ApplyIcon}" Click="MenuItem_Click_1">
<MenuItem.Style>
<Style>
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="MenuItem.IsEnabled" Value="false"/>
</Trigger>
</Style.Triggers>
</Style>
</MenuItem.Style>
</MenuItem>
well I got no way to debug what happened but it certainly didn't disable the menu item when there was a validation error on one of my user input fields
 
change the validation.haserror value to false
and see if its properly disabled from the start
 
yep
so Validation.HasError evidently didn't return true
I wish I understood how HasError is caculated
what controls does it consider?
 
I think it checks if the errorcollection is empty
 
lol non answers
sorry Johan... just a little irritated
getting the feeling I should focus on setting up the logic to now allow the focus to be cahnged
 
6:30 PM
what are you validating btw?
 
and abandon this Validation.HasError thing
Im trying to disable a menu item in the event that any user control anyplace in the app has a validation error
ive set up validation rules for the fields already
Maverik claimed Valdiation.HasError would tell me if any control had an error
but it doesnt
 
pretty sure it does
 
well my text box that's highlighted via the validation rules in a red box, and the enabled menu item beg to differ
 
feels like there should be a bubbling event that signals on validation errors
dunno if there is one
ok time to write some code here then
 
sounds like a scoping issue
you said before you controls are in a tabitem
is the save button also in the tab item?
 
6:36 PM
no
 
the Validation context is probably different
 
the menu is hosted on the main form, the tab controls are embedded content on the form
SEE!!! I freaking knew it
 
try to add a validation display inside your tab item
just to check
 
kk I set up a trigger on a control on the tab
on HasError
testing it now
nope
didn't work for a different control on that tab either
 
then we need a simple repro
because that is basic stuff now that isnt working
 
<ComboBox Margin="3" ItemsSource="{Binding Path=NetworkModes}" SelectedItem="{Binding Path=SelectedNetworkMode.Value}" Width="200" Background="{Binding Path=SelectedNetworkMode.Changed, Converter={StaticResource BooleanToBrushConverter}}">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Converter={StaticResource CustomEnumConverter}}"/>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
^ that doesnt
 
@JohanLarsson you are referencing the textbox
he has dozens of controls
 
yeah, I did not read the question
I never do
 
lol
good man!
I can try to put together an example I suppose
 
Feels like there should be some event to subscribe to
 
6:43 PM
but first
im gunna go smoke a cig.... heres my validators (which im pretty sure are working)
namespace RadioWizard.WPF.GUI.Objects
{
    public class EmailValidator : ValidationRule
    {

        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            string v = value.ToString();
            if (v.Contains('@') && v.Contains('.') && v.IndexOf('@') < v.IndexOf('.'))
            {
                return new ValidationResult(true, null);
            }
            else
            {
                return new ValidationResult(false, "Not a valid email address");
 
^looks promising
we need and event for if validation error goes away also
if we have that it will be trivial to write an attached prop AnyChildHasError
hmm, should be simple any way. An attached prop with inheritance
time to write it now
must afk, it will be delayed
Idea is to write:
<StackPanel x:Name="StackPanel" gifBox:ValidationExt.IsValidationScope="True">
 
im back
 
and have all children report errors to it
feels like the solution will be clean
before getting stuck writing it :)
 
06:00 - 19:0019:00 - 00:00

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