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

12:26 AM
yo who's here?
 
 
3 hours later…
3:13 AM
@DemCodeLines sup?
 
 
5 hours later…
8:08 AM
Morning
 
Hey Sean
 
Morning Sisyphe, how's it going?
 
Hai.
 
Hey Denver, how are you?
 
Good, good.
Looking for a black style for DataGrid.
 
8:13 AM
Cos black is the new black
 
8:29 AM
@Sean
Here we go
 
Morning Asheh =]
 
Deciding the best course of action for this GOD DAMN REFACTOR
 
You should plan it
Find out what you've got, what you need and how you're going to change it
 
Ive written a 50 page TDD
I dont want to do more writing
Haha
 
What's a TDD?
Surely not Test-Driven Development?
 
8:40 AM
Technical Design Document
We have to write TDD's at work before we develop anything
 
Aaaaaah, gotcha
 
Where do you work?
 
That's not a bad thing
I work near Manchester
 
Whaaat
Me too
Where abouts?
 
Rawtenstall
 
8:42 AM
Im at Wilmslow
 
"Near Manchester"
 
North manchester above rochdale
 
Ah yeah you're much closer to Manchester than me
 
Yep
 
I live in Manchester though
 
8:43 AM
Anywhere nice? :D
 
Yeah it's alright. It's right on the edge of Salford nearer to the centre than Salford actually. The MOSI is less than 10 minutes walk from me. I can see their steam trains from my balcony
 
Ah yesss
Went to the MOSI recently to see the hadron collider
 
I've not seen that yet
 
Its OK
Not amazing
 
Bah
 
8:48 AM
Sean, I have another question
So, looking at these DT and DT Selectors
I have some of my forms that are generated "on demand"
Because I tried it with a 15,000 field form and it took forever
So i converted my expanders, so that they only load when they are expanded
Will that cause problems?
I cant envision how it will work, till I get there unfortunately because of my lack of WPF knowledge
 
What do you mean by "only load when they are expanded"?
 
So, imagine the expander contains nothing
 
Right
 
But when you hit expand, it THEN parses my source data, and creates the form
(underneith the expander)
 
WPF has something called virtualisation
 
8:50 AM
Ohh googles
 
But I don't think that's your issue
It sounds like the parsing is taking the time
 
Hmm no
it was creating everything at once
It took about 30 seconds to create the whole form
I'd imagine the more controls you add, the more complex the hierarchy gets and the slower it becomes to insert
 
I have a similar issue in one of my windows
It takes a while to load with thousands of records
Uhm
 
Yeah
How did you solve it?
 
Well, delaying the loading will delay the loading
 
8:52 AM
Or didn't you :D
 
No did I heck
 
Yeah basically I put unloaded content inside expanders
And loaded them on-demand
Loads instantly
 
I slapped a loading screen on that shit and said "When this gets re-written..."
 
Haha, ok so that problem is not solved yet. There must be a way with MMVM
 
Well of course you can lazy-load data and controls
I don't know of any issues
What were you thinking?
 
8:54 AM
Ah
Thats the technical term
Yes I was lazy loading, using expanders
But how does this work with MMVM...
Because for it to work, I had to hook into "On Expanded" -> "Add COntrols"
1
Q: lazy loading in TabControls (MVVM)

Kirill LykovI have an TabControl which displays a collection of my ViewModels. The mapping between ViewModel and View is implemented by DataTemplate. I use MVVM but without PRISM (for historical reasons). The ViewModel’s Base class has a method Load which load information. What I want to do is to call this m...

Might work. I'm going for it(Y)
 
Make a data template, and then don't load the data in the constructor or the Loading event. Use a property and then load it when the data is requested
 
Great plan
 
I'm not exactly sure how you would wire that up but that is what I would try
 
Sean, so ideally. MainWindow would bind its DataContext to my ViewModel
Right?
 
Yes
 
9:07 AM
I have a viewmodelmanager, which creates and switches all the views
 
That's good
 
Although with this binding, it might not be needed
 
You still want a view manager of some sort
To handle navigation between different views, if nothing else
 
Yeah thats what I need it for
But I was thinking if the viewmodel has a property saying which type it is..
Then the datatemplate selector takes care of that
With two way binding
 
Right but you would still need some kind of manager to change the currently active view model, no?
 
9:09 AM
To switch out the datacontexts
Yes you are right
 
That is happening with alarming frequency
Someone with a brain needs to come and put me in my place
 
Lol
Ok so problem that arises
My tab view (which stores each record)
Ill bind it to an ObservableCollection
But then you might be able to switch out the way each record is viewed
But if were binding the tabcontrol to the datacontext
Then we need a datatemplateselector, to decide what view each tab is?
 
You could do that with just any old data template
 
Unless I dont bind the tabcontrol and break MMVM
 
If the types of the objects are different
 
9:14 AM
The types are the same, but you may want to view them differently
Currently its a menu option
 
Alright then, yes. You will want a template selector
If it can be automatic
If you want the user to choose, you don't want it to be choosing for them
 
yes
 
But if the different types of data should always be viewed in different ways, then definitely use a selector
 
So basically ill modify a property on the viewmodel and it should propegate
 
And I believe you can swap templates at runtime too, if you still want to give them the option of viewing the data in a different format
What do you mean by propagate?
 
9:17 AM
well my whole form will appear different
 
Do you mean that if you modify a property on the VM, it should automatically choose the correct data template?
 
yeah
pretty much
I imagine it will just "work" :D
with two way binding
 
Data template selectors don't update automatically
 
Hum
 
But you could use a data trigger and set the template that way
 
9:19 AM
Ah ok
So, this is my plan.
My ViewModelManager, contains an ObservableCollection<ViewModel>. Ill bind my MainWindow tabs to this. Each ViewModel can be inherited
 
Sounds good
 
And then I can have FormViewModel.. TreeViewModel and switch them out. And somehow do some magic
OK
Give me 1 hour
(lol)
 
We're the voodoo, who do, what you don't dare do people!
(cos you said magic)
 
:P
 
9:44 AM
@Sean
I have my tab view now bound, but I am not sure where to go next. To bind each record in my viewmodel
I guess this is datatemplate
 
Yes
So if you have something like your MainWindow's DataContext set to MainWindowViewModel which has a property Tabs which is a collection of TabViewModels then you might create a Data Template for the type TabViewModel
Now you said they would inherit so with your <DataTemplate DataType="{x:Type myNamespace:SomeType}"> you could use the inherited types
 
You can apply datatemplates to specific data types?
 
Yep
 
Thats pretty cool
 
Would be pretty useless otherwise haha
 
9:48 AM
So i guess I define this in my resources somewhere
 
Yep
 
Has anyone worked with ChartPlotter from DynamicDataDisplay library. I need to restrict or limit zooming/panning feature.
 
What I did for my tab control was put the DataTemplates in there but made them go to a user control so everything was nicely separated
I'm sorry Denver, I haven't
 
No need to be sorry, I still love you.
 
<TabControl.Resources>
    <DataTemplate DataType="{x:Type myDataNamespace:MyType}">
        <myControlNamespace:MyTypeView />
    </DataTemplate>
</TabControl.Resources>
Something like that
 
9:52 AM
Damn they do not even have an OnZoom event. If I could detect when zoom happens, would be so much easier...
 
Namespaces never work for me:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="DataForge.View">

<DataTemplate DataType="{x:Type vm:ViewModel}">
<!-- Elements defining the DataTemplate-->
</DataTemplate>

</ResourceDictionary>
Silly thing says ViewModel does not exist inside DataForge.View. But it does.
I remember why I preferred constucting the forms in code now. This stuff doesn't make much sense at the moment :)
 
You need clr-namespace:DataForge.View
 
What is clr-namespace? Just a random keyword?
 
It tells the XAML to look at a CLR assembly/namespace
 
Ok interesting
That seems to compile but still underlines it in the xaml. I did google this but the suggestions I find never worked
 
10:02 AM
Is that the full namespace?
 
Yeah
 
Should work
Try killing the designer and reloading it
 
Weird, So I am binding ItemsSource to my observablecollection of ViewModel's. And then I create a DataTemplate.

I assume datatemplate never assumes where its going to live?
DataTemplate.ItemTemplate doesn't work. Hmm
/me googles
.
 
@NETscape Ye, I think there is no need to improve this, maybe I'll try some other stuff later, but now it is pretty good. I think it is doing better than a benchmark a coworker did with NodeJS
Good morning all
 
Morning
 
10:16 AM
Morning André
 
Sean this stuff isn't easy you cant debug it! Its so much guess work!
 
You can turn binding errors on
How're you doing André?
 
Sleepy but great
Lost 10kg already
 
10:22 AM
AWESOME!! :D
 
Wow Congrats.
 
Cheers Sean.
The distinction I am currently trying to find out is that if you Bind an ItemsSource to an observablecollection (for a tab view)
It has two things. ItemsTemplate and ContentTemplate
But in my Resource Xaml. its just a DataTemplate
Unelss you can do some sort of template-specialization
Its weird because I guess we shouldn't assume that the DataTemplate is bound to a TabView though
So im not sure what the solution is
 
Uhhh
I customised my tab control
Buuut
If you put a data template in there, it will use that for your content
 
But how do you select if you are applying it to the ItemsTemplate or ContentTemplate?
TabControl.ItemTemplate, used to render the TabItem headers
TabControl.ContentTemplate, used to render the TabItem contents
But I dont have "TabControl"
In my resources this doens't work
<TabControl.DataTemplate DataType="{x:Type vm:ViewModel}">
    <TextBox Text="{Binding Header}"></TextBox>
</TabControl.DataTemplate>
Looks like I can only define a generic template
Aha!
This is how its done I think
<DataTemplate DataType="{x:Type vm:ViewModel}">
    <TabItem Header="{Binding Header}"></TabItem>
</DataTemplate>
So presumably, if its a tab item... it uses that
 
10:35 AM
I did it differently
 
Care to enlighten? Because I have no idea what to do
 
<TabControl SelectedItem="{Binding CurrentTab}" Style="{StaticResource MainPageTabControlStyle}" ItemsSource="{Binding PageViewModels}">
    <TabControl.Resources>
        <Style BasedOn="{StaticResource MainPageTabControlTabItemStyle}" TargetType="{x:Type TabItem}">
            <Setter Property="Header" Value="{Binding Title}" />
        </Style>
        <DataTemplate DataType="{x:Type viewmodels:CalculatePageViewModel}">
            <components:CalculatePage />
        </DataTemplate>
 
Falling over at the first hurdle this is not a good sign ! xD
 
That's because I have a custom style for my tab headers
You could do away with the BasedOn bit
 
Hmm, I just cant quite grasp how DataTemplate works with the Tabs
Because it seems you define two sets of data, one for the header and one for the content
 
10:37 AM
No, that's not true
That's why I have the style that sets it
 
Doesn't a DataTemplate define how Data looks?
So my ViewModel. It shouldn't care about what its bound to, right?
 
"how the data shown"
 
That <Setter> sets the Header to the Title property on my view model
 
(well it's the same thing sorry)
 
And then the Data Template just displays the data
Tab controls are slightly different
 
10:39 AM
This is what I have:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:DataForge.View">

<DataTemplate DataType="{x:Type vm:ViewModel}">
</DataTemplate>

</ResourceDictionary>
<TabControl x:Name="TabViewControl" Grid.Row="0" ItemsSource="{Binding ViewModels}" />
 
But generally, a data template is just like saying "For this type of data, use the following controls:" and you can put anything in there
 
Right but how does it know if its putting the controls in the header or the content?
 
Because.....
There is a ContentPresenter in there and that receives the content
Short answer: I haven't a fucking clue
 
Hahaha
So there isn't a solution
 
To what?
You just use a data template to display the content in the main panel of the tab control
 
10:42 AM
Well, I want to bind the Header to "Header"
and Content to something else
But I cant distinguish between them in my datatemplate
 
Use a style
Use a style to set the header
And then have the Data Template handle the content
Which it will do automatically
So, like the code I pasted before
 
OK
 
Do you need the header to be bound to a different field if the type is different?
 
I just need header to be bound to MyData.Header
and then I want to do magic for the content
 
Alright then just use that style code I pasted before
Or maybe...
 
10:45 AM
Its really weird
<DataTemplate DataType="{x:Type vm:ViewModel}">
    <Button>Test</Button>
</DataTemplate>
This creates a button in the header
What am I missing?
Maybe I need an ItemTemplate?
Oh that is a datatemplate
All the examples online ONLY define the DataTemplate outside of Resources
 
Guess I'll go to bed. See you guys in 2 hours!
 
You're insane.
 
lol
 
I think maybe because I explicitly set the header...?
 
This is so confusing
Absolutely zero information about it lol
This doesn't work either
<DataTemplate DataType="{x:Type vm:ViewModel}">
    <TabItem Header="Test">
        <Button></Button>
    </TabItem>
</DataTemplate>
Puts a tab item in the header
this works but seems wrong
<Style TargetType="TabItem">
<Setter Property="Header" Value="{Binding Header}"/>
</Style>

<DataTemplate DataType="{x:Type vm:ViewModel}">
<Button></Button>
</DataTemplate>
 
10:59 AM
Ugh the mighty @Sean is stressed out... :/
 
It must just go, "oh it already has a header"
Magic :)
 

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