« first day (650 days earlier)      last day (3499 days later) » 

5:09 PM
ok i'm late to say this
but why aren't we using Task instead of BackgroundWorker?
 
woot! I solved my arrow animation issue from last night. arrows are matriculating right across the screen. Ty @Netscape and @ReedCopley
 
@ReedCopsey ;) and good job Dread. Do yo have the project on github?
@Julien how/what do you show on your controls when they have validation errors?
 
now to figure out how to rotate the image to have the arrow pointing the right way. (although I may just make 8 images
@Netscape, I am trying to get around to publishing it and blogging about it, but the coding is so much more interesting
 
@DreadPiratePeter RotateTransform
welcome aboard the wpf train :)
 
@NETscape there is a built in error reporting system you can use
 
5:13 PM
@DreadPiratePeter apply a RenderTransform? or LayoutTransform if thats applicable
 
it annotates nice little error messages besides your textboxes for instance
but i didnt find it the easiest to use
 
@Maverik, I could use anything to get this to run but backgroundworker had more examples online
How would I use Task?
 
backgroundworker is also ancient
 
yeah...
 
for running stuff in the background you can use Task, Thread, TaskFactory, or BackgroundWorker
theres lots of articles about which to use in which case
 
5:14 PM
I tried Task but I ran into a few problems
 
we tend to use Tasks now and that's what the new async / await is working with
 
but for basic stuff they are all interchangeable
 
How would I use task for busy indicator?
 
I have been on the wpf/mvvm train for about a year now, just have needed to do fancy effects for work so I am learning them now for my game
 
i went with background worker because he was using it alerady :D
 
5:15 PM
yea i know, i'm not criticising
just saying why not pick the stuff we use in routine
 
@KalaJ exactly the same way. you do your work in the task
 
an example would help
 
await Task.Run(x => { do your thing here });
you may want to read on async / await though along with tasks
 
@Maverik You should use await Task.Run(() => { Do your thing here } );
there are problems with Task.Factory.Run and await in some contexts
 
oh yea sorry
lol i was typing StartNew and then backspaced
thank you for the correction
 
5:16 PM
@Julien right, I have validation rules for my textbox, but I'm trying to get it to show my error message as a pop up or something
<TextBox.Style>
    <Style>
        <Style.Triggers>
            <Trigger Property="Validation.HasError"
                     Value="True">
                <Setter Property="TextBox.ToolTip"
                        Value="{Binding RelativeSource={x:Static RelativeSource.Self},
                        Path=(Validation.Errors)[0].ErrorContent}" />
            </Trigger>
        </Style.Triggers>
    </Style>
</TextBox.Style>
 
I tried using await Task.Run... etc...
but it said something about not recognizing await
even though I put the using System.Threading
 
Master Reed has some excellent articles
 
there's @ReedCopsey, ty for all your help last night. my aroows are moving and grooving
 
and you probably didn't mark your method as Async
 
I did
but that was also not recognized
 
5:17 PM
.net 4 ?
 
no .net 4.5.5
 
wow, beta?!
 
whoa - man from the future!
 
I think maybe I was using it wrong?
lol
 
@DreadPiratePeter Glad it's working
 
5:18 PM
theres no 4.5.5 out yet as far as I know :D
 
just .net 4.5
 
@NETscape you dont like the default annotation? i got nothing on how to style them
 
and you double checked?
 
If I go to About
in Visual Studio 2012
 
Kala give us exact error
 
5:19 PM
oh you are just setting tooltips
 
I don't want just a red box, I want something to popup and show the user rather than having to mouse over it
 
otherwise we'll be here all day
 
It says Microsoft .NET Framework Version 4.5.50938
 
I don't want tooltip though, because you have to mouseover
 
ok let me redo everything and copy and paste the errors
 
5:19 PM
Netscape just edit the Validation Template?
 
I want to show something, aka set the template of the default adorner
 
yeah i am looking
sec
<TextBox Text="{Binding Username, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" />
 
@Maverik I did that, but how do you set the text of the template to use the validation error info
 
So I have something like this
 
5:21 PM
your VM has to implement IDataErrorInfo
 
private void DoSomethingAsync() {

task = Task.Factory.StartNew(() => { ImportCDFilePath(); });
 
I need this info:
Value="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=(Validation.Errors)[0].ErrorContent}" />
in my error template, but dunno how atm!
 
when you implement IDataErrorInfo, you can return a string that is used as the error message
 
umm that will be populated by WPF
 
and it adds an annotation to the field
 
5:22 PM
public ICommand ImportCDFilePathCommand
{
get
{
new RelayCommand(async () =>{ await DoSomethingAsync()});
}

}
 
IDataErrorInfo is one of those ways
but you could do it via exceptions too
 
With just that, I am getting Cannot await 'void'
 
or based off ValidationRules if that's what you're using
 
so I made my method async
 
await needs a Running Task
return a Running Task
 
5:23 PM
So I changed my method to look like this:
 
so return Task.Run( () => {} );
 
private async DoSomethingAsync() {

await task = Task.Factory.StartNew(() => { ImportReagentLotFilePath(); });

}
but now I'm getting 6 errors
 
umm no
await goes on task itself
 
what do you mean?
 
<ControlTemplate x:Key="validationTemplate">
    <DockPanel>
        <TextBlock Foreground="Red"
                   FontSize="12"
                   Text="{Binding RelativeSource={x:Static RelativeSource.Self},
                        Path=(Validation.Errors)[0].ErrorContent}"></TextBlock>
        <AdornedElementPlaceholder />
    </DockPanel>
</ControlTemplate>
 
5:24 PM
remove the task =
 
does not work
 
await Task.Factory.StartNew..
 
still getting a problem
await Task.Factory.StartNew(() => { ImportCDFilePath(); });
with this
 
@NETscape where is the control that is triggering the error
 
though I'd do .Run instead - you don't actually need to grab a thread - just schedule it on pool and forget about it
 
5:24 PM
you dont need to add custom controls to show the errors
 
@KalaJ It should be private async Task DoSomethingAsync() { (note the Task there...()
 
the namespace async could not be found
await opratorcan opnly be used within an async method
 
it's your declaration - not the await
you need a return type :)
 
I know that, I'm trying to style the annotation
Validation.ErrorTemplate="{StaticResource validationTemplate}"
 
ok @ReedCopsey
I did that but now I need a return path
what is meant by that?
 
5:25 PM
@NETscape you are on your own friend :D
 
that is on my textbox
System.Windows.Data Error: 17 : Cannot get 'Item[]' value (type 'ValidationError') from '(Validation.Errors)' (type 'ReadOnlyObservableCollection`1'). BindingExpression:Path=(0)[0].ErrorContent; DataItem='TextBlock' (Name=''); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') ArgumentOutOfRangeException:'System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index'
 
yeah
I use a multi converter in FsXaml to worka round that
 
I'd say just read Reeds blogs before you attempt this stuff!
 
Error 3 'InoPlex2.ViewModel.RViewModel.ImportCDFilePathCommand.get': not all code paths return a value
 
@KalaJ show your whole method
 
5:27 PM
(please don't star that link - we already have it)
 
@ReedCopsey, which method?
 
there's quite a bit of useful stuff in our starbar
please open it up using the link that says "show all 119"
 
@KalaJ The one giving the error
 
The method doing the background task or the async method?
 
and browse through for useful stuff - but read reed's series at minimum on tasks & wpf
 
5:28 PM
@Maverik Especially "hugs" :p
 
The error points to my command
 
a yes, i haven't cleaned up starbar - I'm sorry reed :(
 
public ICommand ImportCDFilePathCommand
{
get
{
new RelayCommand(async () => { await DoSomethingAsync(); });
}

}
 
@ReedCopsey but that doesn't show the validationresult message does it?
 
The red line is under get
ohhh
I need a return
 
5:29 PM
you need to return new....
 
opps thanks
catch it now
:D
Thank you
Okay that solves all the errors
but I am wondering when should I Display my progress bar?
 
@NETscape Yeah - I show it in a tooltip in there
@KalaJ In general, async voids like that aren't a great idea - if there's an exception, it'll completely get swallowed...
 
ahh i see it
 
Might want to read the article in the side bar by Stephen Cleary - he's got some better approaches
 
where can i find ValidationErrorsToStringConverter?
 
5:33 PM
ok
but when should I set the visibility of my progress bar if I'm using MVVM approach?
Before the method is called, during?
Also, I am getting The calling thread must be STA, because many UI components require this.
on this part: (async () => { await DoSomethingAsync(); });
 
found the VEtsC in fsxaml
 
Is it because I have dialogservices/messagepopups inside the method I'm running in the background?
 
@ReedCopsey you still need to mouseover for the tooltip though, right? I'm looking to show or something like a popup, when the control has errors
@Kala yes
 
@NETscape Run the FsXaml demo project
 
hmm
 
5:40 PM
you should really read the link that was posted
 
it's got both - there's one where there's an itemscontrol that just shows errors, and one with mouseover
 
Hi,
 
I am reading it but it's a little dense
 
Hi, I'm newbie with WPF, I want to know what it does not support use SelectAll() method in GotFocus() event of a textbox?
 
The STA error I'm getting it's related to the view for base classes for the dialogs
so I guess I can only perform part of that method inside the task
and the other part outside
 
5:42 PM
@KalaJ You need to do anything touching UI on the main thread
 
I already said you can't do anything UI related on a non UI trhead
1 hour ago, by NETscape
you can't do any UI related things on a non UI thread. that goes to say you can't change any properties bound to the UI on a non UI thread.
 
You can use a custom task scheduler to push tasks back to the UI thread
 
The problem is, the message popups rely on the background task logic
 
I don't want to read, I just want answers Reed.
 
so I was thinking should I separate the method into two or look into reed's post
 
5:50 PM
how the heck do I change the color of a selected item in a listbox from blue to something else in xaml?
 
There is a style for slecteditem. Or at least IsSelected property you can use as a trigger
 
6:09 PM
I have another question
sorry for the trouble
I created a separate method
for detecting the CD-ROM drive
but now, the problem is the busy indicator is on forever
because the logic ever ends
the system found a drive
but how do I exit out
once it's found?
 
turn it off when you want
please don't say you're showing a dialog with a busy indicator on it
 
I created a separate view for it
separate view for the busy indicator
but I am using
        dialogService.ShowDialog("Progress", progressBarWindow);
to show it
where progressBarWindow is a viewmodel
 
is using a dialog the best approach
why not just overlay a tile on top of your window
 
what do you mean? how do I do that?
using a dialog is the only way I know of
 
well for example within a grid, you can stack elements
your busy indicator can just sit on top of your window content
you dont really need a whole new window
 
6:28 PM
oh
 
I may have made a fundamental design error in my roguelike. my Coord type is in integers. Being an old school coder, I had it ingrained in me that floating point arithmetic is expensive long ago. But now my math is all wonky. I probably should have done my Coord class as doubles with an int conversion operator that does the right thing when I need the coord as an int.
 
and set the visibility to collapse or visible when the logic comes?
 
@KalaJ yes exactly
 
Or used the built in Point class I didn't know about
 
that way you can use a simple binding to control its visibility, dont need any code behind
 
6:30 PM
I am using this progress bar
busy indicator
 
sure, doesnt matter
 
for something this complex there is code behind
I'm not sure where to set the visibility
the grid?
 
well you can set it directly on the progress ring itself
or on any container around it
just try to add it without any visibility bindings
and see how it looks
 
add to the viewmodel I need to display it on now?
I mean view
 
you dont need any code behind for this
other then toggling the bool
yeah add it to your view
 
6:34 PM
no code behind for this busy indicator???
 
all you need is a bool to decide whether or not it is visible
 
I have a question
for the progress bar
it is a user control
and I can't add two user controls to one view
 
yes you can
 
just take the grid portion?
 
you can have as many user controls on a page as you want, as long as they are within some sort of container
such as a grid
 
6:36 PM
also it says
content can only be set once
 
yes, you cannot have a page composed entire of user controls
they have to be within a container such as a grid
or a stackpanel
or a listbox
anything
 
nvm got it
thanks
ok added the code behind for the animation to work on the progress bar in the example
now I have something like this
private async Task DoSomethingAsync() {

progressBarVisibility = Visibility.Visible;
await Task.Factory.StartNew(() => { PerformCDDetection(); });
progressBarVisibility = Visibility.Collapsed;
}
but it doesn't collapse after task is run
 
ok first of all, if you are already inside an async task, firing off another task accomplishes nothing
you are essentially starting a thread that is starting a thread
your PerformCDDetection method should be your async method
second of all, does your progressBarVisibility implement INPC
 
yeah it does
 
does it start off as hidden and become visible
or is it always visible to start
 
6:47 PM
always visible to start
 
lets see your progressBarVisibility get/sets
 
opps let me change something in my constructor
for some reason
my application is busy
before running anything. I didn't even click on the button to start the task. The default busy indicator comes up and locks me out
with a task
public Visibility ProgressBarVisibility
{
get
{
return progressBarVisibility;
}
set
{
progressBarVisibility = value;
RaisePropertyChanged("ProgressBarVisibility");
}
}
private const string PROGRESSBAR_VISIBILITY = "ProgressBarVisibility";
 
you have to set ProgressBarVisibility, not progressBarVisibility
 
thank you
it works
but my application has a busy indicator (default wpf one?) all the time from a background process
not sure what it is
it wasn't like that before
 
sounds like you are running something on the main thread when you shouldnt be
 

« first day (650 days earlier)      last day (3499 days later) »