Archive for '.net'

itemtemplate selection by type in xaml only

some days ago i found my self in need to change the itemtemplate in a listbox according to their type. and if with less code as possible. i had done this in a treeview but i couldnt find the code again. so i needed to figure it out again and with some help from a collegue we ended with this:


<!-- more xaml here -->

<ItemsControl ItemsSource="{Binding Items}">
  <ItemsControl.Resources>
    <DataTemplate DataType="{x:Type MyNameSpace:MyType1}">
      <RadioButton />
    </DataTemplate>
    <DataTemplate DataType="{x:Type MyNameSpace:MyType2}">
      <ComboBox  />
    </DataTemplate>
    <DataTemplate DataType="{x:Type MyNameSpace:MyType3}">
      <TextBox />
    </DataTemplate>
  </ItemsControl.Resources>
</ItemsControl>

<!-- more xaml here -->

remark: you arent allowed to give a key to that resources. i suppose the type is kind of key here.

prio conf 28.-29.10. in munich

i am existed about a conference i am attending end of oktober in munich, germany: prio conference. its totally ui centric and that why its so hot. never saw such an interesting conference all about ui in germany before.

what is wrong with focus in wpf

lately we wanted to set the initial focus on a window in wpf to improve the keyboard experience in our app. what we want to achieve is just the initial focus. so when one opens the window he can type or push the most meaningful button instantly. unfortunately we encountered several problems. at first lets see what wpf offers to set the focus. there are at least 4 possibilities:

  • FocusManager
  • Keyboard.Focus
  • InputElement.Focus
  • InputElement.MoveFocus

what i understand from msdn is that the best way to set the initial focus is the focusmanager. but we encountered two problems where that wont work:

  • set initial focus to a button with a commandbinding
  • set initial focus to an element defined through a contenttemplate

i did not understand why that is. but i found two strange things: when setting a breakpoint in the ContentRendered-Event you can see the button is visible, but it is disabled. so i understand that i doesnt make sense to set the focus to a disabled element. this seems like a bug to me. another thing i could not understand is when the content of the control is set through a ContentTemplate the Method FrameworkElement.FindName(string elementName) wouldnt find the element. isnt that a bug too? when you inspect the window on screen with scoop u can see all the elements of course.
i tried to use the other focus-methods in various events but none worked. funny thing: if you set the focus and have a breakpoint in the Loaded-Event and just go on after stopping there the focus is correct. Racecondition?

so is there someone who had similar problems? am i wrong with my feeling that these are bugs?

i added an example solution where you can see the sourcecode.

skillsmatter, london: day 3

man, again a hour too early. but needed to pack my stuff so i arrived at the old sessions house on time. first session with david laribee: “towards a new architect”.

man is dave a good speaker. nice minimalistic slides. and we got teamwork. i think a great exercise was the condensation of team values. we startet in small groups (5 people) – diversion phase. where we found around 25 values. all the stuff that came to our minds. then we voted on the values and found 5 top values (conversion phase, we could have summed al the teams values up but to see how it works it was enough) for which we had to find sentences to declare why we honour that value. dave suggested to print those team values so the team have them in mind always. great idea.

after the usual lunchbox i decided to attend the second workshop from dave. unfortunately it started a bit messy. not everybody understood what to do because the exercises where really abstract. and because i had to depart about an hour too early i couldnt see the end result.

as i mentioned my flight was early so i had to leave skillsmatter at 17 o’clock. too bad because they instantiated a discussion with all the speakers at 18 o’clock and a beer at the crown pub nearby after that. i should have planned my home ride on thursday. hmmm…next time.

baseline:
i think the progressive .net workshops from skillsmatter where great. i had very good conversations (mostly limited by my speaking skills). the speakers where always near. not that they leaved after their talk but one could always get to them and ask questions. the atmosphere was very familiar. i liked the location and the organisation was very good. two things i didnt like: the internet-connection was very bad. that was really really annoying. many attendees had 3g-connections but i think if i had used mine (german provider!!) i think by boss had killed me. the second thing: the lunch boxes where a little small for my taste. but i can recommend the workshops without a doubt.

skillsmatter, london: day 2

i am still not adapted to the hour time difference between germany and the uk. so i awoke a hour to early.

arrived early at the old session house where the workshops take place and decided to hear the f#-workshop with robert pickering. the workshop was full of f# content. robert is real expert. the speed we rushed through the slides was amazing. but at the and we arrived at some beautiful examples of the power of f# which robert ported from python out of the book “collective intelligence” by toby segaran – great read by the way. he drawed some nice dendrogramms e.g. of a blogclustering algorithm.

after the light lunchbag (nearly the same like yesterday) james, david and i got a small beer before we joined the advanced nhibernate workshop with ayende.

wow the room was full. big speaker, big room, big audience – great. so ayende told he has no slides and nothing prepared at all. he questioned the audience to supply topics he would then talk about. he collected about 25 topics…for a 4h workshop…not bad. and it was fun. for example the suggested topic “stored procedures” he wrote down as “stored procedures, and how they bite you in the ass”. ayende is really cool. the rest of the talk was also very passionate.

after that gojko guided the group to the alt.net beers. snacks and drinks where sponsored by thoughtworks and skillsmatter (thanks for that). i learned serialseb is the dictator of the alt.net beers. he managed the geeky crowd to really get to two talks around document databases and bdd. some of the speakers had an alcohol clouded mind to say the least. but it was real fun. it was an amazing day 2.

skillsmatter, london: day 1

so the first day is finished. when i arrived at skillsmatter i met michel. like expected. first talk with ian cooper about internal dsls in c#. cool intro to the matter. now i need to have a look at some stuff:

after that we got a lunchbag and sat in the sun for an hour. then sebastien lambla joined. i didnt know much about him but he seemed funny and interesting so i decided to see his talk instead of the fitnesse one. and it was great. he stated that he had only 3h of sleep because he had to get openrasta to work for the workshop. but he got it and the workshop went great.
when the workshop ended we all went to have a beer. there where some discussions with lambla aka serialseb, oren aka ayende and some other nice guys.
we ended the evening with pizza at pizza express with 14 funny people where we had also some great discussions about latin as a language in school and introducing agile techniques to teams in very big and long lasting projects. very interesting.

know i am done, have a good night

going to london: skillsmatter

i am excited. tomorrow i will fly to london to attend the progressive .net tutorials from skillsmatter. great people will be there: ayende aka oren eini, sebastien lambla and i will meet michel a comrade from the .net bootcamp last year. so i hope i will write some posts from london the next days. stay tuned…

nothing but dotnet – jean-paul boodhoo’s bootcamp

last week i attended in jean-paul boodhoo’s nothin but .net – bootcamp course. this was a great experience.

i read about it in his blog and i could convince my boss to send me there. shure i heard some stuff about it and i read the overview from jp with the disclaimer :

**********Please be aware that the length of course days (based on prior iterations of the course) can fluctuate dramatically based on the level of student interaction. It is best to come ready expecting the course days to be no less than 10 hours.************

but what then happened exceeded all my expectations. jp previously send us prep material about what software to install and how to configure the laptop. he also included a small exercise where we should implement some function, so the tests get green. he also gave us the advise to have a look on his shows on dnrtv. so it is just as you may be thinking now: you can easily spend a weekend or two on the preparations.

after everybody had arrived jp took a look at the excercises we had prepared. then he choose one solution and the magic started. i have never seen someone before who grasps the code of others and navigates through it as fast as him. fast as lightning he refactors and afterwards nothing is like before. it was fascinating but sometimes hard to keep track. fortunately jp recorded everything (as long as anyone reminded him). now we have 6GiB (27h) worth of screencast lying around waiting to see them in slomo.

then we started configuring all laptops to run sql-server (or its express edition) and iis on all those different os (winx xp pro, win xp home, vista 32bit/64bit in german!!) so we all can run the webapplication which we wanted to implement in the following days. here is one of the few things that might be improved concerning the courses to come: the setup of the machines took several hours and at the end not everyone could run the app smoothly. i think it would be helpful to have a different approach to show alle the stuff we wanted to learn during the week. what came to my mind was to use a small wpf app with sql-server compact edition. that way there wouldnt be any complex setup needed. jp appreciated the suggestion. perhaps he will use that kind of environment in his next courses.

the following days we implemented the webstore-app. we mostly used a kind of ping-pong-style. jp wrote a test and we implemented the methods to green the tests. the team (usually small groups of 2-4) that finished the tests at first checked in so the others had to revert their changes and update. that was a bit frustrating when you were part of a slower team and it was hard to follow. but we re-paired perpetually so i think it was ok in the end and everyone was happy. sometime we had an assignment given by jp to implement a story by ourselves so we had the chance to write the tests ourselves.

for me the last two days where the best. i got used to jp’s speed and could therefore follow his curser and ideas more easily. moreover the extreme situation of coding till 4am (up until 18h) welded the team together. i think that is the main advantage of the bootcamp style. if we had the same time sliced in the usual 8h days the team wouldnt have become that close. its is a little bit like other situations where people experience extreme challenges. it brings them together. so i hope i will meet these great guys again. (perhaps just to dive into the memories we all share).

there are many things i didn’t mention here. but if you want to know more about what happened i list some blogs of other attendees:

overall it was a great week. thanks to the awesome team. especially jp who is an outstanding personality. i hope i get the chance to meet im again sometime.

keep on movin

basti