« first day (1535 days earlier)      last day (2614 days later) » 

00:00
it's time
 
3 hours later…
03:29
and I'm here! Happy new year from the UK :)
(yes i'm late.. apologies!)
04:14
@Maverik @JohanLarsson @FoggyFinder Happy New Years!
isn't it a bit too early for you to be up or too late? (either way not a sane hour)
11:14 ... getting close!
Happy new year :)
ah ok - 4:15am 😀 i woke up a bit back :D
hahaha... nice. You're on 3rd shift time now?
its always the case when i'm on holidays
04:16
grin
it usually gets countered by the fact that I change timezones and you don't notice it as much but since i'm still in the uk.. the effect is.. a bit pronounced this time around :)
Going to go take the dog out, then rejoin the fam in the living room for the countdown and some bubbly :)
(its actually getting better - i'm slowly pushing towards morning wake ups)
ok :)
enjoy :)
Hahahaha.. yeah.. really... another few hours :)
Before you know it, you'll be getting up at 5:30am :)
04:35
yup - really just another day and office will start and my shifts will go back to "normal"
btw - lets start New year with a nice link!
^ i think that one has a lot of potential
 
8 hours later…
12:47
3
Q: Scroll WPF DataGrid to show selected item on top

HaimI have a DataGrid with many items and I need to programmatically scroll to the SelectedItem. I have searched on StackOverflow and Google, and it seems the solution is ScrollIntoView, as follows: grid.ScrollIntoView(grid.SelectedItem) which scrolls the DataGrid up or down until the selected ite...

 
8 hours later…
21:07
@JohanLarsson this may be a little too basic of a question, but: how do I expose the property in a custom control properly? Here's my try, but the user control isn't refreshed
I think I need to pass in PropertyMetadata to the DependencyProperty.Register function call
(the goal is to make the text in the third column change the same way it does in the second column)
oh, it is pretty wrong, hold on
and never worry about basic
public partial class MyControl : UserControl
{
    public static readonly DependencyProperty FileProperty = DependencyProperty.Register(
        nameof(File),
        typeof(File),
        typeof(MyControl),
        new PropertyMetadata(default(File)));

    public MyControl()
    {
        this.InitializeComponent();
    }

    public File File
    {
        get { return (File)this.GetValue(FileProperty); }
        set { this.SetValue(FileProperty, value); }
    }
}
my guess is you want something like ^
Dunno if propertymetadata makes any difference there tbh
tip when defining dependencyproperties: use the r# template
dependencyproperty > tab
<Grid>
    <TextBox Text="{Binding File}"/>
</Grid>
gah :)
<TextBox Grid.Column="1" Text="{Binding ElementName=FileListBox, Path=SelectedItem}"/>
you rely on the ToString there
an alternative is <TextBox Grid.Column="1" Text="{Binding ElementName=FileListBox, Path=SelectedItem.Path}"/>
yeah, normally I'd use some kind of converter
maybe r# gives a nag about SelectedItem being object there
or it is smart enough to figure it out, not sure
dependency properties are nasty to write
typically inpc is not needed on controls
usually dependency properties are right there
biggest difference is that you can bind a dependencyproperty and it is usually desired for properties on a control
21:23
why default(File)?
generated by r#, null is fine
but if you do a dp of type double 0 will throw as default value
default(double) and 0.0 will work
oh wait
the analyzer has lots of nags for dps
if I type in null, the different constructor is used
the one that takes a callback
should catch many common bugs
21:26
so (File)null would be equivalent I guess
@milleniumbug oh, yeah, result is the same though
yeah
I'm not sure I have ever written a dependency property by hand
@JohanLarsson replaced the old code with this and it still doesn't seem to refresh
I think I'll need to clone it and have a look then
having another look at the gist first, hold on
try: <TextBox Text="{Binding File, RelativeSource={RelativeSource AncestorType={x:Type local:MyControl}}}"/>
both should work I think
<TextBox Text="{Binding File, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MyControl}}}"/>
don't remember if explicit FindAncestor is needed, think not
I prefer binding like that even if it is verbose
setting self as DataContext feels wrong
another alternative is to not use a dp in the usercontrol
And do: <local:MyControl Grid.Column="2" DataContext="{Binding ElementName=FileListBox, Path=SelectedItem}"/>
And just have <TextBox Text="{Binding Path}"/>
I'd prefer not doing that since that would make the control less reusable
ok
that would be the most standard way to do it
only rarely dependency properties are needed on usercontrols ime
but it is good that you play around and explore
wpf is not very nice here as datacontext is object
21:46
my goal is to move the code from the MainWindow into separate controls
yeah it is getting a bit big
you can try this:
but some of the controls need to expose their own high-level properties
1) take a chunk and move it to a userconrtol
2) replace the code in mainwindow with the suercontrol
everything will work as before as DataContext inherits
meaning it trickles down from mainwindow to the usercontrol
oh right, didn't think the datacontext inheriting would work across different controls
element name binidings will be broken though as the usercontrol is another name scope
21:50
in particular, the BreadCrumbs control could be reused in a different project :)
one would just expose the path as a dp
22:14
@milleniumbug is it working now?
no :/
the textbox inside the control isn't refreshed
I guess I could update it manually instead
should not be needed, did you have a look with snoop?
you can filter out bindings with errors
usually points to where the problem is
@JohanLarsson not yet, I didn't have it installed on that machine
fill fix that soon :)
@JohanLarsson ok that pinpointed the issue with 100% accuracy
the ListBox stores FileItems, MyControl takes in Files
finding the "Show only visuals with binding errors" option took me a while though
22:29
oooh a room dedicated to WPF?
haven't seen this active before
it is pretty active during the weeks
and usually pretty on topic
off topic is fine of course
yea, i haven't been going to SO chat much past 6 months or so
so this is new to me
@milleniumbug it will save you a lot of time from now on
22:55
@JohanLarsson the properties are set properly when examining them with Snoop, now that I have <local:MyControl Grid.Column="2" File="{Binding ElementName=FileListBox, Path=SelectedItem.File}"/> and <TextBox Text="{Binding Path=File.Path}"/> but the program crashes when File is null
I guess it's time for a converter
strange, bindings should not crash on null
ok, maybe it's something different after all
yes, it is something different
disregard the above
enable break on exceptions and run it again
@milleniumbug while not much fun fighting with things like this is a good way to learn
InvalidOperationException: TwoWay or OneWayToSource can't work for read-only-property Path of type WpfScratch.File
ugh, I should have spotted that
23:01
also the exception text is localized lol
<TextBox Text="{Binding Path=File.Path, Mode =OneWay}"/>
I read it as textblock :)
working version?
nice work
commit and install the analyzer now then :)
find some bugs, write some issues
I did install it on two projects and it found like 5 issues with IDisposable usage
which is nice
were they actual issues?
@milleniumbug I meant this which is targeting wpf
23:17
at least two of them were actual issues; not sure about the rest
ok, nice that analyzer is pretty pre alpha
the wpfanalyzer is becoming somewhat stable I think
ah, no wonder haven't found it - I've typed Gu.WpfAnalyzers into search
and this one seems to be missing the Gu. prefix
I had a stackoverflow issue in the idisposable analyzer at one point, killed vs pretty effectively
@milleniumbug yeah moved it to dotnetanalyzers for visibility
was hoping for more issues
pretty sure it will not find anything in the code in the gist as it looks right
23:58
hello

« first day (1535 days earlier)      last day (2614 days later) »