« first day (917 days earlier)      last day (3232 days later) » 

9:49 PM
Okay, next situation/question. I think I have a way to do what I want here, but I'd like a good way. Let me run it by you all and see what you think.
In my UC, I have five Rows in by Button's Grid. Like so:
<RowDefinition Height="20*" x:Name="RowHeight_Blue" />
<RowDefinition Height="1*" />
<RowDefinition Height="58*" x:Name="RowHeight_White" />
<RowDefinition Height="1*" />
<RowDefinition Height="20*" x:Name="RowHeight_Orange" />
I then have three functions which follow this pattern, emphasizing one Row or another:
this.RowHeight_Blue.Height = new GridLength(58, GridUnitType.Star);
this.RowHeight_White.Height = new GridLength(20, GridUnitType.Star);
this.RowHeight_Orange.Height = new GridLength(20, GridUnitType.Star);
On my main display are two Shift buttons, one orange and one blue, and their job is to make all of the buttons 'Orange mode' or 'Blue mode' or 'White mode' (by hitting one of those buttons a second time)
So a way I could make that happen is to change the RowDefinitions above to have Height="{Binding RowHeight_Blue}", for example
 
why dont you bind your height properties against your main window vm
then just adjust them there
 
Then have my blue shift button call a method that makes RowHeight_Blue 58* and the others 20*. RowHeight_Blue, of course, being a public property on my MainPageVM
I'd like to keep my layout encapsulated in my UC if I can, does that make sense?
 
you can still bind against mainwindowvm from your uc
 
But if I understand what you're saying correctly, they'd be something like Height="{StaticResource BlueRowHeight}" and then in Page.Resources, I can do <Style TargetType="RowDefintion"> and use a Setter that has a bound value?
 
i dunno. accessing all those controls by name is silly when you can just have properties on your vm that control it all
Height={Binding Row1Height}
int Row1Height {get;set;}
 
9:54 PM
Yes, sorry, my current markup has x:Names for each of them but I'd do away with that in favor of Height="{Binding BlueRowHeight}" or some such
I think we're saying the same thing
Current markup was confusing given what followed
 
So here's a slightly different idea
 
Sure, lay it on me
 
Make a "ButtonMode" enum, and create a DP for it on your UC
then in the main xaml, bind each button's ButtonMode property to the same VM property
Then your mode switch buttons just change that data
in the UC code-behind, use the DP property changed callback to update the correct properties when the mode changes
That way, you aren't reliant on the parent VM
 
Okay, I don't hate that idea. How do I use those changed callbacks? I haven't done that before
 
In addition to the default value, you pass a delegate to the PropertyMetadata constructor
 
9:57 PM
Or is it just in the setter, like a normal INPC property?
 
@Julien Having View type names in the ViewModel just makes me squirm
Nope, that doesn't work
 
? what view type name
 
Aha, so the 4th param looks like this:
new PropertyMetadata(defaultValue,[callback])
 
your DP way is like a bajillion times more code
 
I'm interested in trying it both ways. If I can get conversant with several techniques for any given problem, then I can get good at this stuff. I really like having you two with your different approaches, as it really enhances my understanding. =)
So thanks for that!
In that DP changed callback, the parameters are: (DependencyObject d, DependencyPropertyChangedEventArgs e)
The DepObj is, what the UserControl itself, or the DP that's being changed?
Nevermind, looks like the second param is really what I want to be looking at
 
10:14 PM
@Julien "Row1Height"
why does the VM care about heights?
@KyleHumfeld Yes, thats the correct signature
The object is the uc
 
it's about the proportion between the heights
 
you are asking why a ViewModel cares about a property that the View uses to control how it displays itself
 
Thats right
 
When the orange shift is pressed, the orange strings get big and the others small
 
that is the purpose of a view model, imo
it means you have a view that is independent of a view model
you can swap in another view model
and have the same view work but look different
 
10:15 PM
@Julien The purpose of the view model is to hold the state and business logic for a view
The view decides how to display that state
Having a property called "Height" in the VM is contrary to that purpose
since height would be very view specific
Even if its relative
 
i think you are very wrong
 
fair enough, agree to disagree
@KyleHumfeld You'll end up using both params
 
Yes, I looked up a doc or two and discovered that =)
thanks for the heads-up though
 
you put your heights in a VM @Julien?
 
@KyleHumfeld One thing to note, this may be a good time to use the VisualStateManager
 
10:18 PM
Not sure what that is
 
For what its worth, here are the docs:
 
does that mean you put your Windows.Visibility, and Brushes.Color, etc. in your VM too?
 
if i had a grid on my form, who's row heights changed based on a button press, then i would put the height of the rows on the view model that the grid is bound to
 
Cool, what's the upshot, like why would this be a good time to use the VSM?
 
but basically, it allows you to have different "states" (strings) that have UI state (heights, colors, etc) associated with them
 
10:20 PM
Huh, interesting
 
The upshot being it would animate the stuff instead of snapping :)
Also, your code-behind just has to switch states
 
Aaah, that's a good thing
 
what the state means is defined in the XAML
For example, I had a card UC
 
And I put the VSM xaml markup in my UC
 
and I had an "active" state that turned the border green
So when I set the "Enabled" DP to true, the code-behind switched visual states and I had a nice color animation to change the border
Thats correct
 
10:22 PM
So in your onChanged handler for that DP, you did something like myElement.VisualState = "Enabled" or some such
 
Right
 
Okay, thanks for the heads-up
That's something where I can do it simply (i.e. a jump-change) and then when that's working, evolve it to use the VSM, right?
 
pretty much
 
You wouldn't pull out a VM and drop a new one in there IMO. Instead you'd pull out a View and drop a view on top of the VM. You can test the VMs + Ms, you can't test the Vs and VMs
 
I like making small hops from working to working with only brief broken in between, otherwise I can get lost in a non-working state =)
 
10:24 PM
Its certainly not a requirement, just super useful for data triggered animations
since DataTrigger got whacked in WinRT
 
@NETscape i dont disagree, but it is still imo by far the easiest and most flexible way to control your UI
 
Totally something that I'll be 100% required to have in here in the end, so I really appreciate the tip! You would have heard about it from me before long otherwise... =)
 
right, which i could agree with. but I think Bradley prefers using animations and what not, maybe even goes as far to say he is creative. On the other hand, I would bind that ish right to the view model as well and call snapping good enough haha
 
all you need is a property and INPC implemented on your class and you have full control over your elements properties
 
Yeah.... if the view model is supposed to control view behavior. Which its not. (again, obviously my opinion).
 
10:31 PM
if you bind a height, then you have to change it, and probably code behind some animation features? Why not just use visualstatemanager w/ a bool which will change the heights of your grid rows
 
i dunno. ive never had to increase a row size at run time
nor do i ever animate anything
 
Curious as to what you all think about this:
2
A: Is there really a universal code requirement?

BradleyDotNETYou already answered the question. If the asker's intent is clear, they have sufficiently described the problem, and the problem is in-scope and on-topic, the question should remain open. No code required. Additionally, if the user showed research effort, the question is clear and useful, etc,...

@Julien your poor users ;)
 
if something needs animating, im probably using 3rd party
lol
 
steal all teh codez. me on bord
 
yes
 
10:35 PM
i haven't had enough time to sex up my app. you're more than welcome to make minez all pretty Bradley
i'm not going to steal code, i'm just going to steal Bradley. I'd sleep with one eye open if I were him
 
lol
I've gotten pretty good at making things "pretty"
doing complex animations, even a card game in the tech makes you do that
I'd be curious to see if @Julien is thinking the same way once he tried to do some of the stuff I have :)
furiously erases all evidence of my location from the internet
 
you still haven't checked your direct messages. :p
 
Just did
I see you now (I think)
Mar 10 sound about right? Or Apr 13?
I think that was the hackathon
probably didn't see it because I was half-asleep
Nope, just after the hackathon
still half-asleep, but not on twitter either :)
 
I can't tell you how happy I was the moment I hit my orange shift buttons and all my buttons went to orange mode. Like holy carp, it worked the first time?!?
 
Lol, thats great
don't get used to it ;)
 
10:47 PM
Nah, one of those blue moons I keep hearing about
 
pretty much
 
@Brad here is the result. (The ribbon dialog)
Hacked a couple of things along the way that I will clean up tomorrow, more a proof of concept.
Also no styling at all as of now
 
Now I really want to try that library :)
wait, what the heck is a ribbon dialog?
 
I don't know English, hold on screenie coming up
A modal dialog that draws over the window
 
i like it very much. can you set the template for the dialog
 
10:58 PM
maybe win 8 has them
 
for eg a combobox
 
@Julien yep, set it to anything via style & controltemplate
 
nice. i am using something similar in mahapps but you cant template the content
at least not easily
 
ModernUi is the same. That is why I forked it. It looks great but not really wpf
Have turned many things into controls now so they can be styled & bound
 
Ah... that dialog
 
11:00 PM
what is a good name for it?
banner?
 
I belive its a "popup" in WinRT parlance
 
overlay?
 
it is a messagebox
 
but they don't have any other concept of a modal dialog
You could call it a ModernModalDialog or something
 
i guess its not really a box anymore. but its the newage version of a message box. lol
 
11:01 PM
thats the clearest though a bit verbose
 
        internal DialogResult RunDialog(ModernWindow owner, IDialogHandler dialogHandler)
        {
            this.Result = DialogResult.None;
            var decorator = owner.AdornerDecorator;
            if (decorator == null)
            {
                throw new NotImplementedException("Refactor dialog to use buttons & result from interfaces");
            }
            AdornerLayer adornerLayer = decorator.AdornerLayer;
            var uiElement = decorator.Child;
            if (adornerLayer == null || uiElement == null)
 
Question about VSMs: are they required to be in a ControlTemplate?
 
I don't think so
I believe you can set it directly on a control
 
^ is perhaps interesting, did not know how to do that
 
So I can put the markup in the element that needs to be changed by the VSM
 
11:02 PM
Right
 
Okay, cool, I'll give that a shot
 
I usually do it on the root element
since it has access to any child controls it may need to mess with
 
Okay, that's fair. A question about animation types
The example in the docs is
<Storyboard>
<ColorAnimation
Now I see that there's a DoubleAnimation, which might be suitable, except that I need them to change to star-values and not absolute values
Is there an Animation type I'm not seeing that would be a fit for that scenario?
 
maybe you can animate a transform?
 
First time I've ever tried an animation, so I really know how to do about 1% of the possibilities. How does one 'animate a transform'?
 
11:10 PM
I'm not sure on animating a GridHeight
I mean, you could write one
not that I'd reccommend it just starting out :)
 
I'm up for pushing my boundaries, but maybe my best approach right now is to do it with like hardcoded values and then move to the next level of complication from there
Is writing one the 'animate a transform' thing that @JohanLarsson was talking about?
 
Nothing built in I can find, here's some examples: http://stackoverflow.com/questions/3181139/animating-grid-column-or-grid-row-in-xaml
http://stackoverflow.com/questions/17265067/changing-grid-columns-rows-width-height-by-storyboard-animation-in-windows-sto
http://stackoverflow.com/questions/2017448/how-to-change-the-height-of-a-grid-row-in-wpf-using-storyboard
Have you dealt with Render transforms yet?
 
Okay, cool, thanks for the links! And no for the Render xforms question
 
@KyleHumfeld it was a shot in the dark, I don't know what you are trying to do
 
So render transforms allow you to manipulate UI elements in a very efficent way
you can translate, rotate, scale, and skew them
and each of those transforms can be animated via a DoubleAnimation on one of their properties
 
11:14 PM
No worries, what I'm trying to do is make my 20*,60*,20* rows into 60*,20*,20*
 
In fact, animating a translate transform is by far the most efficient way to move something across the screen
 
Oooh, that does sound like it would apply here
 
You'd think
but unless you can get that grid to build via translate transforms, probably not
 
I don't necessarily have to use a grid, I could use a StackPanel instead
And then scale the text inside them or something like that...?
That gets problematic when there's no text, obviously
 
would probably look strange
 
11:15 PM
(not all buttons have stuff in every 'slot')
Wow, that does get complicated when you have resizable UI elements, doesn't it?
 
I mean, I don't know what size my app's going to be running in, so the star-sizing is a real godsend
But then... if I can't animate changes to that sizing... hrm
 
While an excellent idea, it doesn't work as well in a relatively sized environment
 
Maybe this is a kick-the-can-down-the-road moment. My final implementation won't actually have 3 strings, it'll have 3 drawn glyphs that will look an awful lot like strings
For the non-symbol characters at least
And those glyphs were developed by someone else and he told me that he'd figured out the sizing and maybe the animation on them too
I'm going to be cracking that open on Monday and seeing what's inside
Darn, thought I was going to go a whole day without VS taking. Nope
 
you got close
If those grapics can be vector, you'll get a nicer looking product btw
Then you can convert them straight into XAML and all the resizing will be much better
 
11:24 PM
BTW - I think you can animate star sizing in WPF, but you have to do it in code - but as long as the GridLength.GridUnitType is set to star, animating the Value property should work (and keep it star sized)
but agree with Bradley - if you keep them vector graphics, it becomes much simpler
 
@ReedCopsey If thats true, you should be able to animate it in XAML as well
just building the property path will be all sorts of fun
As long as you can get to the property, you can animate it
 
yes, they're vector paths, made with Glyphish for our various Mac-based products
So I figured I'd give the VSM example a try just to see it work... how do you debug it when it does [nothing]
 
Any output errors?
 
Like the VSM.ChangeState("Orange"); line is definitely getting called, but the defintions I've set up aren't happening
 
If they are vector, definitely consider converting to XAML.
Check the output window, and perhaps post your state code
 
11:32 PM
Nope, not a one
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ButtonModes">
<VisualStateGroup.Transitions>
<!--Take 2.5 seconds to transition to the PointerOver state.-->
<VisualTransition To="Orange" GeneratedDuration="0:0:1.5"/>
<VisualTransition To="White" GeneratedDuration="0:0:1.5"/>
<VisualTransition To="Blue" GeneratedDuration="0:0:1.5"/>
</VisualStateGroup.Transitions>

<VisualState x:Name="Orange">
<Storyboard>
<ColorAnimation Storyboard.TargetName="BlueTextBlock" Storyboard.TargetProperty="Foreground" To="Indigo" />
Obviously, I copy/pasted a chunk of that from the doc example
An example of one of the targets:
<TextBlock x:Name="BlueTextBlock" Text="Blue" Foreground="LightSkyBlue" Style="{StaticResource UCTextBlock}" />
And the call:
VisualStateManager.GoToState(button, "Blue", true);
That's in the ChangedButtonMode() callback, and button is the DO that's getting changed
 
For what its worth, you showed an animation for "Orange" but went to the "Blue" state
not sure if thats a typo
Oh never mind
 
There's one of those for each color, I just picked the Blue one to copy/paste =)
 
You might not be able to see the difference between LightBlue and LightSkyBlue in your example
Especially since it animates
 
But when I do the Orange animation, it turns that one to Indigo, which should be pretty obvious, and White to Black too
 
I don't see anything obviously wrong, but storyboards, and especially the property paths, can be really tricky
For example, Foreground is a brush
 
11:36 PM
Are there any debugging pointers? Debuggability is key for any programming [anything]
 
Yeah, storyboards are hard, but they usually will throw or show up in the output...
 
yeah, those can be tricky, so I tried to follow as closely as possible with their example
It uses a background solidcolorbrush, but I figured my foreground would be a natural analog to that
 
Wait, what is "button"?
In your call?
You usually pass "this"
 
private static void ChangedButtonMode(DependencyObject buttonThatChanged, DependencyPropertyChangedEventArgs e)
{
CalculatorButton button = (CalculatorButton)buttonThatChanged;
Can't use 'this' in the static method, so had to grab from the first param
 
gotcha, thats ok
What tag is the Visual State XAML under?
 
11:41 PM
Now they are defining their colors differently in the example, and maybe that's the key
<Grid.Background>
<SolidColorBrush x:Name="ButtonBrush" Color="Green"/>
</Grid.Background>
vs
<TextBlock x:Name="BlueTextBlock" Text="Blue" Foreground="LightSkyBlue" Style="{StaticResource UCTextBlock}" />
The VSM XAML is just in the <UserControl> tag without any other parents
Not in <UserControl.Resources> or anything like that
Not even in <VisualStateManager>, just <VisualStateManager.VisualStateGroups>
 
Thats correct
Yeah, see they are directly manipulating the brush
you want to do that to keep it easy
its possible to get it to work the way you are doing it, just non-trivial
Definitely go with the named brush and animate its Color
 
@BradleyDotNET Yeah - you'd just have to not use the GridLength markup extensions in your xaml, so you could set the star sizing type directly - but it'd be ugly ;)
 
Okay, so I changed this:
<TextBlock x:Name="BlueTextBlock" Text="Blue" Style="{StaticResource UCTextBlock}"><!--Foreground="LightSkyBlue"-->
<TextBlock.Foreground>
<SolidColorBrush Color="LightSkyBlue" x:Name="BlueFontColor" />
</TextBlock.Foreground>
</TextBlock>
and
<VisualState x:Name="Blue">
<Storyboard>
<ColorAnimation Storyboard.TargetName="BlueFontColor" Storyboard.TargetProperty="Foreground" To="Gray" />
Ah, should be "Color" not "Foreground" on that last bit
 
Correct
 
No dice when I changed FG to Color
 
11:50 PM
Ok...
And you are triggering the Blue state?
I've never used the durations they way you are, you may try directly setting that on the animation as well
 
I have code that is intended to do that, and it's being run
 
Ok, so thats not it.
 
Didn't know that was an option
 
Yeah, each animation has a Duration property
 
On a lark, I changed the GoToState identifier from "Blue" to "Blueasdf", which does not exist.
No error or warning on that, nothing in Output
 
11:53 PM
lovely, I haven't tried to break it that way before though, so it might be normal
If we can't figure it out, I'll find my code this weekend and bring it with me :)
It is possible!
 
I could get rid of the VSG.Transitions declaration if I set the durations on the Coloranimations themselves, right?
Also, is there any significance to the name of the VisualStateGroup?
I don't think I'm ever using that anywhere
 
hello, do you guys know if there is a way for a class to expose it's configurable settings so that they can be shown in WPF GUI automatically?
 
Doesn't look like it's mandatory, the second example omits it
Crud, gotta hop on a call. Thanks for all your help today, see you Monday and I'll take you up on looking at your working code @BradleyDotNET =)
 
@erotavlas what is a configurable setting
 
@KyleHumfeld Yes, you could get rid of it. No, there is no meaning to the group names as far as I know.
Like in the properties window?
or in the XAML editor?
Both will work if the property is a DP, and it works to a certain extent just by being a public property
 
11:58 PM
In the XAML editor
 
Like for example I have a bunch of processor classes, say one of them transforms a string, and my setting is how much padding to add to the string. But another processor does something else like convert the string to another format and the setting is what format to convert to.
 
I would be very careful with that
you want to remain semantically clear
but that still didn't really answer the question
where do you want this setting to appear?
 

« first day (917 days earlier)      last day (3232 days later) »