« first day (916 days earlier)      last day (3233 days later) » 
00:00 - 19:0019:00 - 00:00

7:10 PM
you love em cuz they make your life easier, assuming they work as advertised?
 
lol, that last bit is the trick
 
lol yep
 
Julien knows my "fuzzy" feelings towards third party libraries from yesterday :)
 
@BradleyDotNET any way to animate text input?
 
is it as bad as obscure 3rd party controls in VB6 for legacy applications?
 
7:13 PM
Like, in office 2013 there's that nice smooth text cursor animation
 
@Jeremy Define "animate"
@MarkW probably
@Jeremy Unfortunately I don't know what you are referring to.
 
@BradleyDotNET Not much of a chance I can do that... but if you're familiar with outlook 2013 or word 2013, when you type, the cursor moves smoothly from character to character - it doesn't just jump to it's location when you provide input
 
Sounds like a translate transform from your description
how to automatically do that so that it matches with text, I have no idea
especially accounting for kerning and such
anyways, I'm out to lunch. Be back in an hour
 
the cursor animation thing is sweet lol
first thing i noticed
wonder how many man hours that took
 
8:14 PM
Design-time VM question. Everyone's favorite topic. =)
I have this namespace and class defined:
namespace MyCalcCS.ViewModels_designTime
{
class CalculatorButtonViewModel_designTime
...
But when I try to use it, I get this error:
The name "CalculatorButtonViewModel_designTime" does not exist in the namespace "using:MyCalcCS.ViewModels_designTime".
 
is the namespace supposed to have using: in it
 
Anyone see the obvious thing that I'm not seeing that would explain why it thinks the class is not defined in the namespace?
Yes, in WinRT, we use using: instead of clr-namespace:, which is the WPF syntax if I understand correctly
Conversely, the following does work in a different file
 
try it in code behind
 
xmlns:DesignTimeViewModel="using:_10biiFinancialCalcCS.ViewModels_designTime"
d:DataContext="{Binding Source={d:DesignInstance Type=DesignTimeViewModel:MainCalculatorViewModel_designTime, IsDesignTimeCreatable=True}}"
I can set design-time VMs in code-behind?
That's neat, didn't realize that
 
no
i mean try to init your view mdoel in code behind
it might illustrate any issues
 
8:18 PM
Aha, I think I understand what you're getting at
will try that, thanks
That does work.
Interesting, the one I said does work... when I go back to that file, it gives me the same error. It didn't do so prior to going to the file
(same error with the corresponding filename, that is)
Oh well, not that important, just helpful for designing and laying out
 
8:33 PM
Bizarre, if I change it to d:DesignData instead of d:DesignInstance, the error goes away. it doesn't load the data, but the error vanishes (I infer that this means that it can find the file at that point, but that could be wrong)
I think it's just not even trying to load it. If I change the name of the file to something that does not exist (adding a 'asdf' to the end of its name), it also doesn't complain
Ironically (?), when I retype the file name just to make sure I didn't mess it up, Intellisense dutifully helps me complete the string, indicating that Intellisense can find the file
 
lol, thats weird
 
8:58 PM
@BradleyDotNET Looks like someone's already asked my question before: stackoverflow.com/questions/15327435/…
 
There you go :)
 
9:10 PM
Say @BradleyDotNET, I'd welcome your input on my styling question, here: stackoverflow.com/questions/29834368/…
It's fresh and new =)
 
Looks like fun
 
That's certainly one word for it =)
 
You break the weirdest crap
 
It's a talent of mine =)
 
Does this have your fix with the default styling as such?
I wonder if the content presenter is getting shrunk on your button
 
9:16 PM
And honestly, I'm not really sure I broke it, I just haven't managed to bludgeon it into working correctly
Yes, there's no default styling for Button elements with no Style attribute (anymore)
Note that the Grid does not take up the whole height of the Button, which... shouldn't it?
 
9:27 PM
Well, yes and no
It will take up the whole height of the content presenter
hence my question
 
I'm not explicitly defining a ContentPresenter
That doesn't mean that I'm not blowing it away accidentally, just not intentionally
Interesting, when I put those RowDefinitions in the outer Grid, it works exactly as expected
But in the Grid that's in the Button... not so much
 
Right
 
I think what that means is that the height of the Button is zero, even though it looks non-zero when I start putting stuff in it. That means that it's being stretched by its content, which means the 20/60/20 math can't happen because the numerator is 0 on all of those fractions
 
You couldn't have totally blown the style away, because you didn't override the control template
 
Hypothesis only
 
9:31 PM
I sincerely doubt that...
 
Is there another hypothesis that would explain the behavior? You have way more domain knowledge than I do, so it could totally be something I've never even heard of
 
Well, I'm wondering what the size of the content presenter is
because that Grid is in one
 
Any idea how I can determine that?
The CP is only implicit as I'm not explicitly defining one, right?
 
right
its going to be in the default button style
which I am currently looking at :)
 
I've got Snoop running, but I'm honestly not really sure what it does as the UI is a little ... sparse
 
9:36 PM
tbh, I haven't tried it with a windows store app, just WPF
Try setting HorizontalContentAlignment and VerticalContentAlignment to "Stretch"
 
Totally understood. I'm a weirdo over here in RTLand
On the Button itself, right?
 
right
 
Oh, that seems to have been the silver bullet
Nice!
Let me verify over in one other file...
Yeppers
Nice, if you want to mention that over in the post, I'll gladly hook you up with the rep. Sorry, I just didn't even notice that property at all. The huge number of methods and properties per element is nice for customization, but not so good for discovery. =)
 
You want to know the trick?
 
Please!
 
9:39 PM
because I didn't pull that out of thin air :)
 
I figured it's experience
 
sort of
so I went and found the default control template
By googling "Windows Store button control template"
And spending some time finding the blasted link
And then I looked at the content presenter, which looks like this:
 <ContentPresenter x:Name="ContentPresenter"
                                          Content="{TemplateBinding Content}"
                                          ContentTransitions="{TemplateBinding ContentTransitions}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Margin="{TemplateBinding Padding}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
And noticed that the Horizontal/Vertical alignment properties were bound to HorizontalContentAlignment and VerticalContentAlignment
and thus guessed that setting those to "Stretch" would do what you wanted :)
I'll definitely post an answer in a second here
 
thanks so much!
And if you've got time, maybe we can talk about DepProps?
 
Sure
just finished posting my answer
apparently somebody beat me to it, but I think my explanation is better :)
I gave him a vote anyways
So, Dependency Properties :)
 
That it is! Upvoted and green-checked. =)
Yeah, DPs. So my UserControl has various DPs, which I've set up in my code-behind. I've also set up the LayoutRoot.DataContext = this; So the code-behind is operating as the VM.
Three of my properties (which I set up with propdp) are WhiteString, OrangeString, and BlueString
Then I'd like for my three various-colored TextBlocks to have their Text property reflect the values of those three strings
I've tried {Binding OrangeString}, for example, but I don't think that's working correctly
Hard to tell because I'm not using the UserControl in my main display and my design-time context isn't working
But the Error area says that 'The member "OrangeString" is not recognized or not accessible.'
 
9:57 PM
Unfortunately, that probably won't work
especially considering the CLR never uses the backing property for the DP
Weird as it is, when its pure view like this, the answer is to stop trying to use MVVM
because even though you might pull it off, its usually more work than its worth
So when I have done a similar concept, I set each TextBlock's text property to the DP value in the Loaded event
If you expect the value to change after that, assign the PropertyChanged callback when setting up the DP, and use that method to update the control
 
Ah, so x:Name the TextBlock elements and then set them in code-behind
Thus the disagreement between you and Julien
 
It was that general direction, yeah :)
 
He uses MVVM for everything, and eventually I might go that way, but for the moment I really need to learn how to use DPs, and this is a good testbed for that =)
 
If you are using UserControls correctly, they very rarely need a view model
 
But their property values are going to be driven by the main display's VM
 
10:00 PM
Because the UserControl should just be a display for data, it shouldn't hold any data itself
exactly
 
Or could
Oh, and the error message I typed up before was from the Main display, not the UserControl. I didn't mention that earlier
 
Its not breaking MVVM
 
So the Main display isn't seeing the UC's DPs
Hey, look, I'm using lingo =)
 
because you are just having the UserControl, which is just a special view, update its own display based on the data coming in from the view model
 
I must be learning something
 
10:01 PM
Sure, that makes sense
Can you show me a sample DP?
 
And my markup over in the Main view is something like this:
 
Say, the OrangeString one?
 
<local:CalculatorButton
Grid.Row="10"
Grid.Column="2"
Command="{Binding Button0_ClickCommand}"
WhiteString="White String"
OrangeString="Orange String"
BlueString="Blue String"
/>
 
Okay, that looks fine
 
public string OrangeString
{
get { return (string)GetValue(OrangeStringProperty); }
set { SetValue(OrangeStringProperty, value); }
}

// Using a DependencyProperty as the backing store for OrangeString. This enables animation, styling, binding, etc...
public static readonly DependencyProperty OrangeStringProperty =
DependencyProperty.Register("OrangeString", typeof(string), typeof(CalculatorButton), new PropertyMetadata(0));
That's all from propdp. Only thing I'm not sure about is the 3rd param in the .Register() call
 
10:03 PM
hmmm.... that should work
The third?
 
typeof(CalculatorButton), this being the CalculatorButton usercontrol
 
right, you are registering that DP for that kind of UC
 
Right, thought that was correct, but wasn't 100%
 
Did you try just running it?
 
Won't build
 
10:05 PM
With the same "Cannot find OrangeString error?
 
Saying the four DPs in my UC aren't found, yep that error
 
Ok, here's a dumb question, where is that code?
 
Also, it says my UC doesn't contain a def for 'InitializeComponent'...
 
Well, there's your problem ;)
 
Do I only run that on Page subs?
 
10:06 PM
No, the DP decleration is in the control code-behind
Oh, and InitializeComponent should be on all view classes
 
Which this is, right?
 
Right
So make sure your x:Class and code-behind match up and all that goodness
 
And it's saying that 'The name "LayoutRoot" does not exist in the current context", even though one of my elements has an x:Name of "LayoutRoot"
There was a naming discrepancy. Fixed that up
A couple of the errors went away, including InitComp() and the x:Name one
But not the member-not-found errors
In fact, those are the only errors it's showing right now
 
Ok, so is the DP decleration in the right spot?
 
Good question
 
10:09 PM
and will it build?
Because usually XAML parse errors like that won't kill a build
 
namespace _10biiFinancialCalcCS
{
public sealed partial class CalculatorButton : UserControl
{

public string WhiteString
 
Okay, that looks like the right spot
 
So they're in the class declaration
Is there somewhere else I need to declare them (like in the xaml) so the other xaml can see them?
 
No....
Could you gist the code-behind?
 
Sure, one sec
 
10:11 PM
Just want to check for anything out of the ordinary
 
Hangon, just Built, and the errors went away. Still won't compile because the type or namespace "MainCalculator" could not be found in the App.xaml.cs.
Sometimes I've seen that happen when the xaml for that file is messed up
 
well, that was easy :)
 
Now for the nearly-impossible part - figuring out why the file that's clearly there isn't being found
There's no info it gives me... is there a technique I can use to find out what's messing it up?
Otherwise, I have to just guess and try and comment out swaths of code in files that I think are likely a culprit. Which is not very efficient, and not very effective.
 
lol, no question about that
So in App.xaml.cs, it says MainCalculator doesn't exist?
btw, this is pretty much a checklist here
The next ones are:
1. Is the class for that object actually called that?
2. Does the x:Class match (it probably does, given the lack of an InitializeComponent error)
3. Are the namespaces all correct?
Hi @Mehrad
 
The NSs are all the same, with a couple of exceptions (design-time vm, for example)
The class is called that:
x:Class="MyCalcCS.MainCalculator"
namespace MyCalcCS
{
public sealed partial class MainCalculator : Page
 
10:17 PM
alright...
Are you starting the correct project?
 
Hmm, let me make sure
 
Alternatively, is a page named that in both projects?
 
The page named that is in Shared, but though the BigWin project couldn't find it, the WinPhone one could... victory? Not really, but enough that it's no longer a show-stopper until I get back to BigWin
 
One thing that could help is checking which project the error originated from
So you didn't rename the page in the main one
I ran into that doing my universal app a few times :)
 
Yeah, it was the BigWin one. That one comes up by default whenever VS crashes and restarts
 
10:19 PM
The startup project will get saved in the suo file
so normally closing/restarting VS may save that change off
 
Yes, in the App.xaml.cs in BigWin, it calls MainCalculator, which exists in the Shared area
 
right
 
Okay, now that I've got [anything] compiling, let me try out what you told me about the DPs
 
Shared projects are a bit.... weird
very cool, but weird
 
Oh, but the BigWin project won't compile. The WinPhone, which has exactly the same line, will.
 
10:21 PM
Yes....
You need a "MainCalculator" page in the BigWin project
 
... why?
 
because the App.xaml.cs file is effectively being copied into both projects
 
Can't I use the same xaml file in both projects?
 
so its looking for something called "MainCalculator" when building BigWin
You mean MainCalculator.xaml?
 
or for both projects, yes, MainCalculator.xaml
 
10:23 PM
maybe, though you usually wouldn't
since the layout on WindowsStore will be so much bigger
Pro tip: NEVER change the startup object name
just causes pain
 
Okay, so let's assume that I'll eventually have a MainCalculator.xaml in both projects. Right now, it's in neither, but it does compile for WinPhone
 
Ok, that should be good enough for now I would think
 
Ah, okay, I can change it back
Or have MainPage.xaml push immediately to MainCalculator.xaml
Though that makes me feel slightly dirty
 
Or just rename MainPage.xaml MainCalculator.xaml
and associated class names and such
like I said, pain
 
yeah, probably not worth it. If I just always use MainPage, then there's never any question as to which one comes up on startup
Downside is that it's not all that descriptive, but that isn't a huge problem
 
10:28 PM
The nice thing about startup objects is that the really don't have to be descriptive
in fact, keeping them consistent makes it obvious that it is a startup object
and so differentiates it from the rest of your controls
 
Definitely
Interesting, now that I'm trying to use those DPs, it's giving me this error:
System.InvalidCastException was unhandled by user code
HResult=-2147467262
Message=Unable to cast object of type 'System.Int32' to type 'System.String'.
Source=MyCalcCS.WindowsPhone
StackTrace:
at MyCalcCS.CalculatorButton.get_OrangeString()
at MyCalcCS.CalculatorButton..ctor()
at MyCalcCS._0biiFinancialCalcCS_WindowsPhone_XamlTypeInfo.XamlTypeInfoProvider.Activate_11_CalculatorButton()
at MyCalcCS._0biiFinancialCalcCS_WindowsPhone_XamlTypeInfo.XamlUserType.ActivateInstance()
InnerException:
On this line:
public string OrangeString
{
get { return (string)GetValue(OrangeStringProperty); } <-- THIS LINE
set { SetValue(OrangeStringProperty, value); }
}
The call to that UserControl is here:
<local:CalculatorButton
Grid.Row="10"
Grid.Column="2"

WhiteString="White String"
OrangeString="Orange String"
BlueString="Blue String"
/>
I don't think it's getting to this line quite yet:
this.OrangeTextBlock.Text = this.OrangeString;
Or maybe it is, as that's the only call to the getter
Let me step through and verify
Yes, that's the line that it's crashing on (so it is getting to that line)
Interesting. I refactored the getter like so:
get {
var x = GetValue(OrangeStringProperty);
return (string)x;
}
and put a breakpoint on the return line so I can see x. It's 0, and appears to be an Int, which is consistent with the error message
The getter is calling GetValue, which grabs from here:
public static readonly DependencyProperty OrangeStringProperty =
DependencyProperty.Register("OrangeString", typeof(string), typeof(CalculatorButton), new PropertyMetadata(0));
The the 'new PropertyMetadata(0)' putting the '0' in there?
 
yes
do "null" instead
the argument you are passing PropertyMetadata is the default value
The empty string would also work
 
10:44 PM
:228910 Hi there :) the message got crippled somehow
@BradleyDotNET Hi there :D
 
Aaaah. I read through a bunch of docs, and none of them said that. That would have been 1000x as helpful as the stuff it did say, which was pretty unintelligible.
Will try that, thanks!
 
lol
the second parameter to that constructor, if you use it, is the PropertyChanged callback
just so you know
 
second? Or fifth?
There's a constructor with 5 params, I figured given the naming that param 5 is the callback
 
nope, there one with 2 that will do it
 
Or is it 'new PropertyMetadata(null, [callback])'
 
10:47 PM
at least in standard WPF
yep, that one
 
Aha, thanks
Looks like you can't set a .Text property to null. Good to know!
 
Huh, thats odd
oh well, the empty string it is I guess
@Mehrad How have you been?
 
Nah, I just check it when I get it and set it to "" if it's null
Cleaner that way I think
Looks like when the constructor is called, the dps are all null though
Is there a different method I should put those assignments in?
 
Loaded
 
Aha, figured it was something like that, thanks!
public void OnLoaded() is the method sig, or is it something... else?
Or are there snippets to have it build that for me?
nvm, I think I figured it out
 
10:59 PM
You just need to attach an event handler to the Loaded event
 
Kinda cool that you can do this.Loaded = whateverIWant
That's not natural for me yet =)
 
Hopefully you meant += :)
 
Yeah, sorry =)
It wouldn't compile with just =
 
Well, depending on the class, it actually can
Specifically, you can clear all event handlers by setting to null
 
Don't tell me that =)
Aha, that does make sense I suppose. But lifecycle methods really really shouldn't allow that IMO
Okay, next question. I'm full of 'em!
Is there a good way to scale the font size to fit the available area?
 
11:01 PM
You can also single assign a event handler, but only within the declaring class
Viewbox
 
I'll look that up, thanks
 
pretty much your only option I can think of
Technically that scales more than the font, but it will do what you want
 
That'd be a sub-element of the <TextBlock> right?
 
No, wrapping the TextBlock
Viewbox fills its container and scales its children to fill itself
well, it can fill its container
I believe thats the default behavior though
 
Okay, cool, thanks for the info
 
11:11 PM
@BradleyDotNET I am good. Been busy with the electrical side of the project so not much time to expand my C# knowledge
Some good C learning though
as I haven't done C from since left uni. and this compiler uses C for the microprocessor we use so getting into ti
different world I'd say
Just then was reading about Macros and their difference with functions.
Not sure we have something similar in C# like macros.
 
No, not really
Can't say I've missed them though
 
11:38 PM
Quite useful. This info might not be of any use for you but since I learned it then, I am like preaching it
Using Macros over function wisely makes heaps of difference in this scenario at least. As macros are preprocessed rather than compiled so you calculate the values you need using your powerful PC resources and when compile starts the microprocessor already has all the values it needs in those areas and doesn't need to calculate them as if they were done by functions with it's teeny tiny processing power and resources. :D
all these new things you learn everyday :D
 
Yeah, I know that one
you can do the same thing with meta-tempaltes in C++
not that I actually know how to do that
but I get the concept
 
00:00 - 19:0019:00 - 00:00

« first day (916 days earlier)      last day (3233 days later) »