« first day (711 days earlier)      last day (3438 days later) » 

11:00 AM
That magic?
 
wpf is magic
makes up its own rules
 
Sup @DreadPiratePeter
 
Bollox, I just reproduced my code without my custom styles and you beat me to it
 
Haha
 
Oh I know why it works....
 
11:02 AM
You do?
 
Because it will walk up the logical tree until it finds an appropriate style or template. So first off it looks for your header and finds a style in the current control's resources. Great. Next it wants to find a template for the content. It walks up the tree until it finds the data template in the window/container's resources and uses that.
Boom.
 
haha
 
First come, first serve
 
Absolute madness
ok I see
Tabs appear to be a special case
 
Yes
 
11:03 AM
Because you bind to the observable collection and your datatemplate (for each tab) has two things, the header and the content
so it doesn't know what to apply the datatemplate to?
so if you beat it to it, it just sticks it in the content
 
Yeah, pretty much
 
I have to say Sean. The fact this has taken me all morning worries me about this refactor process
lol
 
Hahaha
You don't need to refactor it. I mean, it was working before right?
But you totally should, because it's better like this
 
Yes
Im creating a specialised view which will need a lot of code behinid
unless I improve the process
So im doing it now
I need to learn this shit anyway, ive shy'ed away for too long
Purely because of shit lke that, where I just could not get it working
I had to do magic
Now... collections inside of datatemplates I guess
 
11:20 AM
morning guys
 
How do you define subclasses?
DataType="{x:Type db:Database.DataField}"
Cannot find the type 'db:Database.DataField'
 
Morning DPP
 
11:41 AM
@DreadPiratePeter Morning =]
@Asheh If the type is compiled and exists in that namespace, it will find it
 
Morning
 
Mav! <3
 
@Asheh regarding your expander and stuff -- the problem is in parsing data or in creating controls? (i think its the later)
if it is, then instead of lazy loading the data - lazy load the controls
 
I knew someone with a brain would come and save me :D
 
Creating the controls
 
11:43 AM
well that is what virtualization is supposed to do but frankly it sucks as far as I've experienced it.. so instead i resort to trigger -> Setter -> Property="Content"
 
Yeah thats what I was gong to do
If I ever get that far
 
so leave expander empty by default, but upon IsExapanded True -> Set Content to whatever
 
hmm ok
 
when the expander collapses, your content will be null again (it reverts back to default when trigger is no longer valid)
it'll keep your visual tree to a minimum, yet everything is there
 
Thats great
So this is triggers
 
11:45 AM
minimum visual tree = low memory foot print + performance
 
yep
 
triggers... master them and you've mastered most of wpf magic
Data Templates + Triggers = pretty much all wpf magic
 
I bloody hope so
Because its causing me some headches moving over to true MMVM
 
Sean's done good.. I'm merely expanding on it -- not to take away his thunder at all
 
He's so nice to me
 
11:46 AM
well thats because you're forcing us to do mental translation to MVVM everytime you write that!!
right, i'm still reading transcript
 
So what im trying now is my ViewModel is bound to an observable collection. Am I right in thinking, that can contain another ObservableCollection which I can define another DataTemplate for?
 
Of course
 
Pretty awesome
 
oh another point -> DateTemplates are basically DataTemplateSelector that is keyed on Class Type
 
So, DataForge.Library is my namespace
My class is Database.DataField
 
11:49 AM
keep that in mind when you're wondering, how will the view know what to render
 
Hmm ok
<DataTemplate DataType="{x:Type db:Database.DataField}">
    <Button></Button>
</DataTemplate>
 
so you need a selector when you can't base your decision off Class Type
 
Right
 
yea so that'll make all DataFields an empty Button
 
Which is my plan I think
Its not finding it though
 
11:50 AM
still, DataTemplateSelector isn't always an option - Triggers will rescue you there too
 
Cannot find the type 'db:DataField'. Note that type names are case sensitive.
Its all LIES
 
db: is defined?
 
xmlns:db="clr-namespace:DataForge.Library"
 
show db decleration
is the type visible?
aka public
 
I assume so I use it everywehre
 
11:51 AM
you can use everything with internal too
 
The designer lies all the time
 
public class DataField : NativeObject
public class Database
 
also, designer works with compiled assembly
so it can't see if you haven't compiled yet
 
this is on compilation
 
well out of ideas then!!
 
11:52 AM
Lol :(
Maybe it cant see nested classes...
 
What's the full type name including the namespace?
 
no nested shouldn't be a problem
whats NativeObject decleration
 
So elsehwere I use:
Library.Database.DataField myField;
public class NativeObject : BindableObject
public class BindableObject : INotifyPropertyChanged
 
Library is namespace or class?
 
Namespace
 
11:54 AM
well sounds like you're doing it right
 
My VS designer is constantly lying to me
 
Yea
Yeah it lies to me too
 
I re-compile and it whinges even though I know it's there
 
probably can't figure this without looking at your actual code / project
 
So ignore it and I compile
 
11:54 AM
2013+ ?
 
So I just ignore it and test it
I use 2013
 
2010s designer sucked
 
Im on 2012
 
but 2013 is much better at it and its rarely wrong
2012 should still be ok
 
Ill upgrade
 
11:55 AM
2013 kind of almost works
 
and 14 is exciting
i think by 2020 - VS will finally consume R# completely!
 
It still can't find types from shared assemblies even when the reference is there and the XML namespace is correct
 
Upgraded! Maybe it wont lie now
 
whoa that was fast!
 
I've had it installed for other poecjts :)
 
11:56 AM
shared assemblies - as in portable or universal?
 
"NEsted Types are Not Supported"
 
Standard .Net
Full CLR
 
well at least now you know!
 
It whinges like a bitch
 
Lol
 
11:56 AM
i thought it did
 
Apparently not
 
but gods can be wrong!
xD
 
Now I have taught you somthing!
 
yes - thank you demi-god asheh
 
That really sucks
now I have to fix up all my code
 
11:57 AM
well this is another something i've learned over the years
 
dont code?
 
POCOs are your best friend
don't code? i was coding when i was 8.. i dont know any other way to live!
 
Who is POCO? a pokemon?
I think i started about 12 :)
 
Google DDG is your second best friend ;)
 
Find and replace may save me here
Wish me luck
 
12:00 PM
Good luck
 
Luck wished +1
 
@Asheh, Resharper will fix all those namespace woes, it automatically finds the right namespace for stuff and generates the references
 
£184 ill have to speak to my baws
(probably one of the cheaper licences we would buy here :P)
 
Resharper is the single best investment you can make for C#/wpf coding
 
looks like visual assist
 
12:12 PM
a little , but it is so much more. it helps everywhere, I can't imagine coding without it
 
Ill check it out:)
Grid cant take ItemsSource. But I want to lay my items out in a Grid. DataGrid exists but it seems a little too verbose for my purposes
 
Grids don't give you grids with items either
 
Hmm
I need somthing which iterates an observable collection then uses templateselector to determine how to display each item
 
Maybe a ListView with a grid as its container and use Shared Size Groups?
 
ListView, that might work
 
12:18 PM
Lunch time, brb
 
<DataTemplate DataType="x:Type db:DataField">
    <Grid>
        <Button Content="{Binding Value}"></Button>
    </Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type vm:ViewModel}">
    <ListView ItemsSource="{Binding Fields}"></ListView>
</DataTemplate>
So, ItemsSource (fields) which are of type DataField
should use the datatemplate?
 
aaarrgh, I would love to get my hands on the MS programmer who implemented "The given key does not appear in the dictionary" error. putting the key it was looking for into the error message would probably have saved me 200 hours of debugging by now.
 
@Asheh Yeah, you can use data templates anywhere in content controls =]
 
Amazeballs just gotta figure out how now
I hate how most of the examples dont use an external resources.xaml file
and the code is completely different if you are
 
@DreadPiratePeter I really hate that. Null references in lines with more than on nullable type. You couldn't have given us a clue as to which variable it was, could you? (I realise that variable names aren't compiled but even the type would do)
@Asheh Naaaaah it's all the same :D
 
12:33 PM
Ive defined my template selector but you cant do this in the xaml:
<fv:FormViewTypeSelector>

</fv:FormViewTypeSelector>
because ofcourse, it doesnt't know about it. I dont think
 
Give it a key
 
Oh hm ok
 
and set the DataTemplateSelector property like so: DataTemplateSelector="{StaticResource KeyNameOfTheSelector}"
{StaticResource} or {DynamicResource}... I'm actually not sure on the difference between the two
 
Using a .... Setter?
 
Maybe @JohanLarsson knows
@Asheh No just straight on the control
 
12:35 PM
@Sean what is the q?
 
My control is a datatemplate
So I need to choose how to display "DataField" based on my selector:
<DataTemplate DataType="x:Type db:DataField">
    <Grid>
        <Button Content="{Binding Value}"></Button>
    </Grid>
</DataTemplate>
So the contents of that
 
DynamicResource is resolved at runtime and can change, for theming etc.
Staticresource is resovled when build and can never change
Static is more efficient and should be the default if dynamic behaviour is sought
 
That makes sense, thank you!
@Asheh It goes on the container. In this case you want ItemTemplateSelector if you're using a ListView
But there is usually some kind of TemplateSelector property on items controls
 
Ahh
That makes more sense
 
I had to look it up haha
 
12:39 PM
I wouldn't know what to search for! lol
 
"WPF ListView" then to the MSDN documentation page then Ctrl+F and "Selector"
 
So I dont need to override my DataField anymore
interesting
 
What do you mean?
 
Well ItemsSource is based on ItemTemplateSelector
so the way each item is displayed depends on that selector
 
Yes
If one is defined
 
12:41 PM
AMAZING
 
But like Mav said earlier, you only need to use a template selector if you can't differentiate by type
 
Well the "type" is defined inside of the DataField
So I guess I need to
 
So it's the value of a property of field then?
 
What do you mean? sorry
 
Your type is DataField, it will have a field or property, e.g. TypeOfView that might be "Spreadsheeet" and you're basing it off that?
 
12:46 PM
Yes
Its more like "boolean" or "integer" or "color picker"
 
Yeah, that's when to use a template selector =]
 
This is for the individual fields
Not the overall records
:) great!
 
@Asheh as in from Whole Tomato ?
 
Hmm?
(visual assist?)
I am getting closer:
TypeSelector cannot be found
Maybe staticresource isn't the same inside of a resource dictionaryu
 
hah, here is a hack-y solution to finding which key is not in the dictionary. I made a key property in the class, then in my method I search/replaced _data["{keyname}"] to _data[key="{keyname}"] , then wrapped the whole thing in a try block that catches KeyNotFound and prints out the key property
 
12:51 PM
Yea Visual Assist sorry.. i was picking up from where i left off
R# is in a league of its own -- as somebody who came from visual assist background
not only does it assists - it teaches... you'll learn quite a few tricks as it suggests small things and start to realise how much you were missing out
 
Yeah so far its great after 30min lol
 
my entire LINQ learning came from R# 7 and that alone was worth its price (i had a personal licence)
there's things in r# that you don't realise for months until one day.. you go aha!
example, it has special implementation for IEquatable<T> & INotifyPropertyChanged .. but if you haven't asked it to implement those for you - you'd assume it'll do default implementation of throw NotImplementedException();
also, if you let it use Jetbrain annotation on INPC when it generates, it'll then provide intellisense in string property names!
 
@DreadPiratePeter Im not sur what you mean?
 
the refactoring stuff is amazing too
 
still another perk of that: now it'll let you create full property change notifications from auto properties
oh yea
 
12:56 PM
Ive also tried local:TypeSelector
 
and R# 9 is looking even better!
 
Its the same as in this tutorial tech.pro/tutorial/807/…
 
I have a new trick it enables, If I need to use a variable/parameter over and over when developing a method, I give it a one character name while writing the method, then when I am done I have resharper rename it to a longer descriptive name and it fixes all the references perfectly
 
Generally when you use resources, define their keys before you use them
it'll save you some headache
so define Selector before you put it in ListView for example
 
Oh really
I didn't realsied it was parsed like that
Thanks
 
12:59 PM
yea its top to bottom
 
My parser works better
 
it wouldn't matter so much in RD because when you'll include it, everything will be defined at runtime
 
Lol
 
but designer will likely moan as you're typing
 

« first day (711 days earlier)      last day (3438 days later) »