« first day (1375 days earlier)      last day (2774 days later) » 

9:19 AM
Hello.. Anyone here?
 
Need quick help in WPF MVVM.
 
Ask away
Don't ask to ask just ask
 
okay. thanks.. let me share the problem...
This is my first MPF MVVM app to work. What I want to do is : I want to share the ViewModel across other views and I have done this with the help of Google and Stackoverflow. Now What I want to change the view at runtime:

<Window x:Class="Wpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
like in "vm:AmericanFootballViewModel" there can be more than one views to display.
I'm able to load the Home and then "AF_Scoreboard_No_Video"
but when I one more view in "AmericanFootballViewModel" DataTemplate it throws error
 
you need a container
 
9:29 AM
My requirement is :
1) Common ViewModel for each game like Football, Hockey, etc
2) Eack game can have more than one Skin (UI -I'm using UserControl for this)
3) User can change selected game skin
okay
thanks. let me search for "container"
 
a panel more precisely
grid, canvas, stackpanel...
 
ok. let me try each.
if you have any reference link plz share
 
how do you want your multiple views to be arranged ?
 
Actually I have a web interface with the list of Games and Skins(Views). User will select the Game and Skin from there suppose

Game = American Football
Skin = Scoreboard_With_Video

is set, then via SignalR this parameters will be passed to WPF application and WPF application will have to do the needfull.

Till now I'm able to change the view from "HOME" to "Scoreboard_With_Video". But Now I want to add more views in WPF "AmmericanFootball" game so that the can be applied.
as this is my first WPF+MVVM app that's why things are tough and taking time for me. :)
 
ok, so you want to be able to dynamically change the datatemplate applied to your VM
 
9:42 AM
Yes. Correct. But not able to add... this is the important
 
stackoverflow.com/a/29777424/885507 do you think this can work?
ok. Let me try. thanks
 
you could also use define triggers in a style
 
okay. Thanks
I have put your all suggestions in a table and try each one by one. Thanks for your time and help :)
 
you're welcome
 
9:55 AM
Hi guys
can anybody help me with this question please:
1
Q: Getting inappropriate output with left join

LearningI am trying to get list of variants and for each of this variants get all subvariants list irrespective of where subvariants fall for particular Test say 100.This is sample data: Id TestId SourceSubVariantId TargetSubVariantId DiffPerc 114 100 66 67 ...

 
not again T_T
 
did i ask a bad question?
 
you didn't ask any
 
you have any idea ???
 
no, sorry, you have to simplify your question (a lot)
 
10:11 AM
@Learning Yeah, frannsu is right. You have a huge, complicated query. Try breaking it down to its components, seeing the intermediate results, then compose it again.
 
ok thank you guys
 
10:32 AM
0
Q: Single Touch Read as Scroll Action

Steven WoodI have a WPF application which is designed to be used on a touch screen. I use a list view with a set of images, with the selected image appearing in a full size image control When on touch screen I can select the images simply by touching the image on the list view item however I have a small ...

 
Is there a way to pause on ALL exceptions including those caught?
 
11:05 AM
@Asheh Yes. Go to Debug -> Exceptions -> check the box marked "Thrown" next to "Common Language Runtime exceptions"
 
 
1 hour later…
12:33 PM
0
Q: WPF Resources.ContextMenu.MenuItem binding to ContextMenu.PlacementTarget.(AttachedProperty)

Scott Brickeyif the title didn't scare you away, here goes... <UserControl.Resources> <!-- so the attached CustomObject can bind to the context --> <my:BindingProxy x:Key="DataContextProxy" Data="{Binding}" /> <!-- for chaining IsNull to Visibility.Collapsed --> <my:ConverterGroup x:Key="IsN...

 
1:05 PM
'morning!
 
'orning.
'fternoon, to be exact.
 
1:27 PM
@JohanLarsson I think I'm ready for more katas
 
oh, nice
what was the last thing wed did? combobox?
maybe a quick style kata
 
let's see, some binding to combobox and checkbox
 
Have you used styles before?
 
...styles?
probably not
 
ok, lets do a simple one then
 
1:38 PM
Morning
 
@milleniumbug make ^ using a Style for TextBlock. I just put three textblocks with hardcoded text 1,2,3 in a stackpanel.
As always ping for hints or links to tutorials if you want.
 
2:06 PM
not using autoformatting today so the formatting may be worse
(different computer)
 
nice
I wrote it like this:
<Window.Resources>
    <Style TargetType="{x:Type TextBlock}">
        <Setter Property="Foreground" Value="Blue" />
        <Setter Property="FontSize" Value="36" />
        <Setter Property="TextDecorations" Value="UnderLine" />
    </Style>
</Window.Resources>
<StackPanel>
    <TextBlock Text="1" />
    <TextBlock Text="2" />
    <TextBlock Foreground="Green" Text="3" />
</StackPanel>
 
should do one with BasedOn
pretty useful
 
bug already did, that was planned for step 2 :)
 
:D
 
Took me a while that TargetType doesn't propagate when using BasedOn
 
2:09 PM
Setting only TargetType and not x:Key makes it implicit
And <TextBlock Foreground="Green" Text="3" /> setting Green here overrides the value in the style
 
yeah
 
Lunch is ready now. Next kata can be: bind background or border brush in the previous app to Gender with a converter.
Did we use gender for the combobox?
 
I just saw that you did {x:Type TextBlock} so you don't need to style individual TextBlocks
 
mmmmm Lunch :)
 
pretty cool
@JohanLarsson yeah
 
2:12 PM
ok, bind background to gender with a converter such that male gives blue bg and female gives hotpink
 
hehe
so I should get the previous solution and modify it?
 
yeah, if you still have it around
if not you can whip up a new with jst a bool prop and bind background to it
Not important, kata is about using a converter in the binding
 
yeah, that one is a bit complicated so removing stuff may take more time than creating from scratch
 
hold on
<Grid>
    <CheckBox x:Name="CheckBox" />
</Grid>
use ^ and bind background of the grid to IsChecked of the checkbox
 
I have a textblock that I'm trying to set to have text wrap, but it's not working. I tried giving it width="*", but it didn't affect anything
 
2:17 PM
there is a wrap property on textblock iirc
 
@Hypersapien <TextBlock TextWrapping="Wrap" ... />
It doesn't force a wrap unless you set the width. Otherwise it wraps based on the parent container width.
 
This would be a lot easier if the dropdown in VS would show anything containing what you type instead of just attribute beginning with what you type
 
@Hypersapien Intellisense does show contains matches, not beginswith matches.
 
Not on mine it doesn't. In fact it doesn't even filter. It just goes to the point in the list that matches what you type.
Of course, this is VS 2010
 
Ah. Lemme fire up 2010 quick.
@Hypersapien Works for me:
 
2:29 PM
THis is actually silverlight. Maybe that makes a difference.
Also, I added TextWrapping and nothing changed
 
Try setting width on the TextBlock smaller, just for test - Width="50px" if it wraps then it's a layout issue, not a TextBlock issue.
 
^ good suggestion
 
Right. An actual number works. How do I make it expand to the width of the parent, though?
I tried * and it just crashed
 
HorizontalAlignment="Stretch"
 
I already had that set
 
2:41 PM
@JohanLarsson trying to write a ValueConverter, but not sure how to access style static resources of the window from it
 
Just make sure that the parents of the TextBlock somehow restricts its Width, this types of issues arise when the TextBlock is inside a panel that gives infinite available width to its children -> Horizontal StackPanels or Grid with ColumnDefinitions with Auto widths.
 
@milleniumbug you dont. the converter returns a xaml acceptable value, like Visible or Color.Red
 
@Hypersapien you should set the background color of your parent and make sure it is as wide as you think it is
 
@milleniumbug don't, hardcode the returnvalues in the converter ... ? Colors.Blue : Colors.HotPink
 
2:43 PM
A grid with ColumnDefinition of "*" width should work.
 
Did that too
Here's what I have the textbox is the one on line 32
 
Is implementation of ConvertBack necessary?
 
nope, just throw NotSupported there
 
the example on wpf tutorials just returns null
ok
 
Sometimes you want it but most often not
I prefer throwing to returning a random null but depends I guess
I'll be afk for a while now, reading when back
 
2:47 PM
@JohanLarsson me too, not too long ago I spent 3h debugging a problem that was silenced with an empty catch block
If it was just propagated further it would be visible immediately.
 
morn
 
morn
 
Nulls are similar in that the problem travels further, but you don't know the true source so the problem is hidden
 
i still thinking using DataTriggers instead of Converters for finite value scenario is better than creating converters over and over
DataTriggers show your intent clearly and are faster usually than converters
not only does it travel further, it also mutates the problem. the real error may be server is too busy but all you get is NRE
so first you have to figure out where in the world you get NRE from and why cos it wouldn't make sense upfront.. and then actually figure out the real problem
 
precisely
I'm not a fun of nulls
 
2:50 PM
nope, there's almost no room for null in modern world
Enumerable.Empty<T>()
even if you're expecting to handle one value but there's a chance you'll end up handling more down the line.. Enumerable.Empty<T>() is much better than return null or false
it'll scale automatically if you end up with more results and in worst case it won't do anything
 
Why does the following code return a null ref exception on the .Equals() check but not on the == check?
string hello = null;
Console.WriteLine(hello == null);
Console.WriteLine(hello.Equals(null));
 
GetMyPie().Any() -> Eat();
lol thats one of the intervew questions :)
 
I know :)
 
because you cant call an operation on a null object
null.Equals doesnt mean anything
 
@Alex Dereferencing null by using dot operator results in a NullReferenceException
 
2:54 PM
== is an operator taking the form (Object A, Object B) and its first check should be Object.ReferenceEquals(A,B) -- which will deal with null
and not throw
hello.Equals is calling Equals on hello object which is null and thus no operation can be performed
 
OTOH passing it as an argument doesn't dereference it
 
Thanks. That was soooo obvious I feel like saying "Duhhh"
 
I feel noob for not using dereferencing O.O
upvotes million millenium bug s
 
meh, it feels a bit unclear
inb4 a question why calling extension method doesn't result in NREs
 
Well, I finally passed my certification last week from CNNA -- Certified Noobs of North America. Feel very proud. Will hang it in my cubicle
 
2:57 PM
umm grats?
 
I know, a proud moment
 
shuold I google that? :D
 
prob
 
it tells me i dont know how to spell shit
 
See, my noobness is contagious
:)
 
2:59 PM
Coalition of Norwalk Neighborhood Associations
Corcoran Nelson Nardone and Associates
 
There's actually a Certified Noob -- lolking.net/summoner/na/19410643
 
Culture-Negative Neutrophilic Ascites
 
What the...? Wow, didn't know such a thing existed
 
laugh
 
As duckduckgo said.. ask and you shall receive.. and receive i did!
 
3:09 PM
never realized poke has 121k rep...
 
yup, I was even more surprised by his meta rep :D
I've often wondered why he graces us noobs with his presence :D perhaps its to save time when people flag things?
 
@milleniumbug is the converter done?
too lazy to read the transcript
 
i had one wrong edit review and i'm banned for 2 days from reviews lol
it was a 99% valid edit
 
@JohanLarsson This is what I have now, but it doesn't work (i.e. the colors don't change at all, and the initial value is white) gist.github.com/milleniumbug/bf5be826d63d8b382f7349711ceb340a
It feels like it should be working, the debugger stops on Convert
 
converter looks right
 
3:21 PM
and the input values are correct
 
what does the xaml look like?
 
It's right below the xaml
 
oh sry
strange, wtf, looks perfect
IsChecked is bool? but should still work I think
 
how do you know my name, mav ?!
 
maybe it is null first causing the converter binding to break
 
3:22 PM
, ElementName=CheckBox,
should that be there?
ah yes, sorry
 
@milleniumbug try: return Equals(value, true) ? Colors.Blue : Colors.HotPink;
 
if that was the issue, it wouldn't ever be white, would it
does checking the checkbox even fire the converter?
 
maybe not sure
yeah, good test @milleniumbug put a bp in the convert method and toggle the checkbox
 
i bet if you changed IsChecked to be a VM property it would work
 
@JohanLarsson yeah, it stops on the breakpoint
maybe Background property expects something different
 
3:28 PM
oh, yeah sry my bad
 
-1
Q: C# - pass command line args to COM component in WPF project

Tyler ZaleSo here is the setup: C# WPF main project using xaml for layouts We have an ancient MFC activeX / COM component that takes uses CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); to get the command line params and operate based on them. This old project cannot be changed :( Wi...

 
should be Brushes.Blue : BrushesHotPink
megaderp
Background expects a Brush
sry about that
 
yay it actually works
 
good times
 
@JohanLarsson no problem I actually tried returning Colors.Blue beforehand
 
3:29 PM
you can try a variant now
    public class BoolToColorConverter : IValueConverter
    {
        public static readonly BoolToColorConverter Default = new BoolToColorConverter ();

        ...
 
what's that
 
try using Converter="{x:Static ???}" and not a keyed resource for setting the converter
@milleniumbug I added a static readonly field to the converter
 
yeah but what for
 
just a variantion, will let you try x:Static which is useful at times
I often add static fields to converters like that, think it is simpler/clearer than keyed resources
But in most examples you will see keyed resources
 
@JohanLarsson more elastic imo too
you can pass arguments to the constructor
 
3:34 PM
@milleniumbug kata reasons :)
 
ok, finally working example, updated
 
nice!
We can revisit the style thing a bit now
Move the style to App.xaml and run it
 
ok, will try some time later
 
(works the same but now it is shared for the app)
 
gotta return home
 
3:37 PM
ok
nice work today, much faster now
really boring kata coming up in a while, unavoidable though
 
how much are you taking @JohanLarsson ? :)
 
taking?
 
as a WPF instructor
$$$
 
:)
bug is our friend, it is an honor to have him in the room
 
still, nice of you
what's the boring kata about ?
 
3:43 PM
I'm thinking it is time to do a listbox
maybe not so boring but a bit more boilerplate with viewmodel etc
 
4:29 PM
> GET BACK TO ME IMMEDIATELY.
^ nice spam, wouldn't read it if I knew who sent it :D
 
:)
 
maybe answer 'sup?' after two months?
 
4:56 PM
Hey, I feel cheated -- don't remember any katas when I was starting here ;)
 
haha, sry
I lured bug in from another room though
 
No worries, just teasing :p
You and the other friends here have been lifesavers
 
5:36 PM
I fear we are losing Reed.
 
He might be busy
He's not on the c# room
 
weird, I can't make the project I did at work to work at home @JohanLarsson
> The name "BoolToColorConverter" does not exist in the namespace "clr-namespace:Katas".
 
try rebuilding
the designer is dumb
maybe rebuild and close all windows
and of course check that the file is there
 
Do a clean as well
Or does rebuilding do an implicit clean?
 
think so but never hurts
sometimes deleting bin & obj folder solves it
But for bug I think building twice may be enough as it is the first time he builds it on this machine
 
6:04 PM
@milleniumbug does it build?
 
No :/
For now I'm installing updates for VS
 
wtf
try closing all documents and building
 
is everything exactly the same? same namespace?
namespace Katas
{
    class BoolToColorConverter : IValueConverter
 
@Alex Laugh.. you wrote your own katas :)
 
6:20 PM
enough with the katas, i want katanas
 
@LynnCrumbling Yeah, I guess I did
 
6:38 PM
@JohanLarsson Ok, restarting and creating the project from scratch helped
I find it quite impressive that the color constants in VS are underlined with a color of the constant
maybe that's Resharper's behaviour
 
maybe, I can never tell what is vs and what is r#
time for next kata?
 
for now I'm not sure what do you mean by moving the style into App.xaml
oh, into the Resources section
 
oh, just cut paste the text in window.resources to app.xaml
Makes it global to the app
 
oh, ok
 
Makes most sense when unkeyed perhaps
 
6:42 PM
I'll just go with the next kata
 
Like my textblock style, that way you can change fontsize in the entire app in one place
@milleniumbug ok a) round button b) listbox?
 
listbox
 
grejt, coding it up hold on
 
6:54 PM
@milleniumbug Use a ListBox to render this, here is the c# for the model stuff to save you some time.
I'm giving you two hints right now: DataTemplate, ItemsSource
 
7:12 PM
Suppose you have an editable ComboBox bound to an OC<string> currently. Now the user wants to see a description next to the value, so if the dropdown now shows 123456, it needs to show 123456 - Description of Code Goes Here
It's easy enough to concatenate the two columns from the db and show them, but when editing, she'll only know the numeric part for a new code. We'll have a nightly job that will pull the description
 
sounds like you need to retemplate the combobox
 
Hmm, I think I just figured it out while typing. Have the Text property of the CB just write the numeric part to the db
 
another option could be to show the description in a textblock next to the combobox
 
Thought about that. Have the textblock change on change of the CB
 
second is probably simpler and perhaps better ux
 
7:15 PM
I like it :) It's elegant too
Thanks, Johan
So you'd have [ComboBox] [TextBlock]
 
Think so, at least I think I'd try that first
 
Can a method name be present twice but with two different return types?
 
having description inside the combobox can perhaps be confusing
what can be edited etc
 
Yeah
 
@Alex nope
 
7:19 PM
Thought so
The signatures must differ
 
7:38 PM
if it is an interface method you can do it though but must be explicit implementation
IEnumerable.GetEnumerator...
 
Is there a reference for the data binding expressions? I'm still trying to read tutorials, but they don't really explain what is the syntax for these
 
@alex yes
and it is called function overloading
 
They do hand out examples, but these aren't enough
@JohanLarsson
 
Yep, another one of those interview questions, overloading vs. overriding
 
for example, what do the braces mean and when they are necessary
 
7:44 PM
Overloading can have two different return types
same method name, but different return types and parameters (number and types)
 
hmmmm, this is slightly more helpful than the rest of the examples I found
 
@milleniumbug what do you mean by braces
in xaml
 
okay, so <Window ... DataContext="{local:Foo}"> and <Window ...><Window.DataContext><local:Foo/></Window.DataContext> are different
hey, this actually works
I mean, I don't have First name and Second name bound, but two rows are displayed
 
@milleniumbug searching, hold on
@milleniumbug the curlies indicates that it is a MarkupExtension
 
@milleniumbug oh.. it is markup extension {} escape sequence:
it is used when Binding
or strings
to make it literal
 
7:56 PM
@milleniumbug skimmed this, looks ok
You already know most you need to know about bindings
 
I almost have it, it's just the TextBoxes's width isn't stretched to the width of the window
 
@milleniumbug you want a hint? It is not obvious
 
put its Width="Auto"
 
okay, quick search over autocompletion didn't help, so
yeah, I'd like a hint
 
7:59 PM
google: HorizontalContentAlignment
long word, maybe I misspelled it
 
nope
 
8:13 PM
Okay, this is what I currently have gist.github.com/milleniumbug/67377c5667fcdb187bb9accbf52aa5ef @JohanLarsson
can't get the stretching to work
 
    <ListBox ItemsSource="{Binding People}" HorizontalContentAlignment="Stretch">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
@milleniumbug try ^
could be a typo, edited in chat
note that I removed the star heighted last row as it did not make sense, minor
would have rendered the same with it
 
nope still broken
but the reason it's broken is different
 
ugh, second <ColumnDefinition Width="*" /> missed that
 
the column is wide for the entire window
 
snoop is pretty good for troubleshooting stuff like this
 
8:20 PM
gotta add a border
 
nah, no need, you passed the kata :)
I added the border to make it easier to tell what item was which in the gif
 
ok, I have the border now
 
ok, nice work
^ is next kata, same listbox & c#
 
8:28 PM
maybe tomorrow
 
Johan, a neat kata down the road would be to have a ListView showing multiple subtypes of data. Hint: They're all of one parent type, but each one has its own fields and layout
 
hint: ItemsPanel
@milleniumbug np
@Alex yep, nice one
 
Sooner or later, you'll have to do one of those in WPF
 
@milleniumbug spoiler in history if you feel like testing it
this is where wpf is pretty nice imo
 

« first day (1375 days earlier)      last day (2774 days later) »