Blog Home  Home Feed your aggregator (RSS 2.0)  
kevin Mocha - Wednesday, July 30, 2008
Bookmarks collected from web.
 
 Wednesday, July 30, 2008
 Friday, July 18, 2008
 Wednesday, July 16, 2008

To solve this, we have to manually add the mouse event handler onto the controls and set the handled parameter to true.

this.tbId.AddHandler(TextBox.MouseDownEvent, new RoutedEventHandler(tb_mouseDown), true);

Wednesday, July 16, 2008 10:06:03 PM UTC  #    Comments [0]    |  Trackback

_strandGroup = this.listViewGroups.SelectedItem as StrandGroup;

Wednesday, July 16, 2008 2:33:50 PM UTC  #    Comments [0]    |  Trackback

<GridViewColumn Header="Strand Type">
     <GridViewColumn.CellTemplate>
             <DataTemplate>
                    <ComboBox SelectedValue="{Binding Path=StrandId}" SelectedValuePath="Id" DisplayMemberPath="Name" Width="120" GotFocus="ComboBox_GotFocus" SelectionChanged="ComboBoxStrandType_SelectionChanged"
                                            ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:LongitudinalStrandGroupsAssist}}, Path=MPrestressedStrands}"/>
             <DataTemplate>
     </GridViewColumn.CellTemplate>
</GridViewColumn>

Wednesday, July 16, 2008 2:32:24 PM UTC  #    Comments [0]    |  Trackback
 Tuesday, July 15, 2008
 Wednesday, July 09, 2008
 Friday, June 20, 2008

From http://dotnet.org.za/rudi/archive/2008/03/25/10-things-i-didn-t-know-about-wpf-data-binding.aspx

 

1) Binding path "(TextBox.Text)" vs "Text"?

If you bind to a path called Text, WPF uses reflection to resolve the name. If you use the class-qualified name, binding avoids the reflection performance hit. Class-qualified names also allows binding to attached properties!

2) WPF doesn't raise exceptions to notify you about data binding problems

All binding errors are output as trace information and NOT exceptions!

Beatriz Costa (Who else) has a excellent article about this

3) Why use OneWayToSource binding mode?

Well, the target object must always be a DP! The most common use of OneWayToSource mode is to by-pass this restriction! The source doesn't need to be a DP and effectively using OneWayToSource reverses the binding direction.

A perfect example is Run, it's text property is not backed by a DP!

4) Default binding mode?

Not all DP's have the same default binding mode!!!

If the binding mode is two-way, but the CLR property that it is bound to is read-only... will cause problems! just keep in mind that you can't assume what the binding mode is!!!

It is always a good idea to explicitly specify your binding mode. Also remember that OneWay is slightly lighter than TwoWay!

5) RelativeSourceMode.PreviousData

If you bind to a collection of prices and need to show the change from the previous price to the current price then this little trick can be very useful... Pass the current item and the following binding into a IMultiValueConverter converter

{Binding RelativeSource={RelativeSource PreviousData}}

The multi value converter now just need to work out what the difference is!

6) RelativeSourceMode.FindAncestor

This is a very cool hack I found... Lets assume that you have a ListBox showing data. Normally if you have a TextBlock inside your DataTemplate and you don't supply it with a foreground color, then it would inherit the parents Foreground property. What is cool about this is that then when you click on the item, the font color would change from black to white! Now assume that your DataTemplate also contains a custom control that do not rely on the Foreground property to determine its color (As a example, I will use a Ellipse which has a Fill and not a Foreground/Background). If I add a Ellipse to this DataTemplate and  I do not set its fill, it would stay blank. Even if I give it a Fill color, it will fill with this color but if I now select this ListBox item, it will stay the provided color!

So how do I make my ellipse inherit the Foreground color and more importantly, how do I make it change to white once selected? Binding its Fill with the following

{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=Foreground}

Now, it will inherit the parents Foreground and also change once selected...

7) Binding a ListBox to a custom object, What gets displayed in the ListBox?

When binding to a custom object, determining what is displayed in the ListBox can be one of 3 options

  1. Set the DisplayMemberPath on the ListBox to a path
  2. Create a DataTemplate
  3. Override the ToString() on the custom object. If no DisplayMemberPath or DataTemplate is found, the ToString() is called on the custom object.

8) {Binding Path=/}

Bind to the current item in the view! Just remember to set IsSynchronizedWithCurrentItem to true

[UPDATE] While reading Ian Griffiths blog, I found a entry detailing this behaviour in WPF databinding

9) Binding has a constructor that take Path as a parameter

This is just a small shortcut

{Binding Path=Name}

Can be written like this

{Binding Name}

10) {Binding}

This looks a little weird but all this means is that the source is defined somewhere up the tree... common place is Window.DataContext. By setting the DataContext to a collection, I can now add a ListBox to the visual tree and then binding this ListBox's ItemsSource to {Binding}. This will tell the ListBox that its ItemsSource is the DataContext of the Window!

Friday, June 20, 2008 5:39:03 PM UTC  #    Comments [0]    |  Trackback
 Tuesday, June 17, 2008
 Tuesday, June 03, 2008

http://edu.sina.com.cn/en/2008-06-02/105342486.shtml

  1. Do you have any pet peeve? 你有什么样的怪毛病吗?
  2. Maybe I’m going out on a limb, but I think we still have to invest it.或许这么作有点冒险, 但我想我们还是要投资它.
  3. I don’t have skeleton in my closet.我没有什么不可告人的秘密.
  4. Are you sure you are going to set us up?你确定你要帮我们制造机会吗? (fix up, hook up)
  5. Probably. It’s still up in the air.大概吧. 但还不确定. "I haven’t decided yet." "I haven’t made my mind yet." 或是 "We’ll see." 就可以了, 不然的话你也可以小小地卖弄一下英文, "It’s up in the air."
  6. Okay. Just checking.好吧. 我只是随囗问问.
  7. Do we need to hit a shower first?我们需要先洗个澡吗?
  8. That’s OK.不用了.
  9. Just right place, right time.只不过是天时地利而已.
  10. Same here.我也是.
Tuesday, June 03, 2008 2:15:51 PM UTC  #    Comments [0]    |  Trackback

      God works. 上帝的安排。

  Not so bad. 不错。

  No way! 不可能!

  Don't flatter me. 过奖了。

  Hope so. 希望如此。

  Go down to business. 言归正传。

  I'm not going. 我不去了。

  Does it serve your purpose? 对你有用吗?

  I don't care. 我不在乎。

  None of my business. 不关我事。

  It doesn't work. 不管用。

  Your are welcome. 你太客气了。

  It is a long story. 一言难尽。

  Between us. 你知,我知。

  Sure thing! 當然!

  Talk truly. 有话直说。

  I'm going to go. 我這就去。

  Never mind. 不要緊。

  Why are you so sure? 怎么这样肯定?

  Is that so? 是这样吗?

  Come on, be reasonable. 嗨,你怎么不讲道理。

  When are you leaving? 你什么时候走?

  You don't say so. 未必吧,不至于这样吧。

  Don't get me wrong. 别误会我。

  You bet! 一定,当然!

  It's up to you. 由你决定。

  The line is engaged. 占线。

  My hands are full right now. 我现在很忙。

  Can you dig it? 你搞明白了吗?

  I'm afraid I can't. 我恐怕不能。

  How big of you! 你真棒!

  Poor thing! 真可怜!

  How about eating out? 外面吃饭怎样?

  Don't over do it. 别太过分了。

  You want a bet? 你想打赌吗?

  What if I go for you? 我替你去怎么样?

  Who wants? 谁稀罕?

  Follow my nose. 凭直觉做某事。

  Cheap skate! 小气鬼!

  Come seat here. 来这边坐

 

      Dinner is on me. 晚饭我请。

  You ask for it! 活该!

  You don't say! 真想不到!

  Get out of here! 滚出去!

  How come… 怎么回事,怎么搞的。

  Don't mention it. 没关系,别客气。

  It is not a big deal! 没什么了不起!

  thousand times no! 绝对办不到!

  Who knows! 天晓得!

  Have a good of it.玩的很高兴。

  Don't let me down. 别让我失望。

  It is urgent. 有急事。

  Can I have this. 可以给我这个吗?

  It doesn't take much of you time. 这不花你好多时间

  Drop it! 停止!

  Bottle it! 閉嘴!

  There is nobody by that name working here.這裡沒有這個人。

  Easy does it. 慢慢来。

  Don't push me. 别逼我。

  Come on! 快点,振作起来!

  What is the fuss? 吵什么?

  Still up? 还没睡呀?

  It doesn't make any differences. 没关系。

  It is a deal! 一言为定!

  Take a seat! 请坐!

  Here ye! 说得对!

  It can be a killer. 这是个伤脑筋的问题

  Don't take ill of me. 别生我气。

  It's up in the air. 尚未确定。

  I am all ears. 我洗耳恭听。

  Right over there. 就在那里。

  Get an eyeful. 看个够。

  Here we are! 我们到了!

  I lost my way. 我迷路了

  Say hello to everybody for me. 替我向大家问好。

  Not precisely! 不见得,不一定!

  That is unfair. 这不公平!

  We have no way out. 我们没办法。

  That is great! 太棒了!

  You are welcome! 别客气!

 

      I'm bored to death. 我无聊死了。

  Bottoms up! 干杯!

  Big mouth! 多嘴驴!

  Can-do. 能人。

  Don''t play possum! 別裝蒜!

  He neither drinks nor smokes. 他既不喝酒也不抽煙。

  Make it up! 不记前嫌!

  Watch you mouth. 注意言辞。

  Any urgent thing? 有急事吗?

  Good luck! 祝你好运!

  Make it. 达到目的,获得成功。

  I'll be seeing you. 再见。

  I wonder if you can give me a lift? 能让我搭一程吗?

  It is raining. 要下雨了。

  I might hear a pin drop. 非常寂静。

  Don't get loaded. 别喝醉了。

  Stay away from him. 别*近他。

  Don't get high hat. 别摆架子。

  That rings a bell. 听起来耳熟。

  Play hooky. 旷工、旷课。

  I am the one wearing pants in the house. 我当家。

  Get cold feet. 害怕做某事。

  Good for you! 好得很!

  Go ahead. 继续。

  Help me out. 帮帮我。

  Let's bag it. 先把它搁一边。

  Lose head. 丧失理智。

  He is the pain on neck. 他真让人讨厌。

  Do you have straw? 你有吸管吗?

  Don't make up a story. 不要捏造事实。

  Absence makes the heart grow fonder. 小别胜新婚。

  She make a mess of things. 她把事情搞得一塌糊涂。

  He has a quick eye. 他的眼睛很锐利。

  Shoot the breeze. 闲谈。

  Tell me when! 随时奉陪!

  It is a small world! 世界真是小!

  Not at all. 根本就不(用)。

  Let's play it by ear. 让我们随兴所至。

  Wait and see. 等着瞧。

  Why so blue? 怎么垂头丧气?

  What brought you here? 什么风把你吹来了?

 

      Hang on! 抓紧(别挂电话)!

  Leave me alone. 别理我。

  Chin up. 不气 ,振作些。

  You never know. 世事难料。

  I stay at home a lot. 我多半在家里。

  She'll be along in a few minutes. 他马上会过来。

  I'm not it a good mood. 没有心情(做某事)。

  He is a fast talker. 他是个吹牛大王。

  Daring! 亲爱的!

  She is still mad at me. 她还在生我的气。

  I'll get even with him one day. 我总有一天跟他扯平

  Hit the ceiling. 大发雷霆。

  She's got quite a wad. 她身怀巨款。

  I don't have anywhere to be. 没地方可去。

  I'm dying to see you. 我很想见你。

  I swear by the God. 我对天发誓。

  Nothing tricky. 别耍花招。

  You might at least apologize. 你顶多道个歉就得了。

  Price is soaring, if it goes on like this, we shall not be able to keep the pot boiling. 物价直线上升,这样子下去,我们锅里可没什么东西煮饭。

  None of you keyhole. 不准偷看。

  You don't seem to be quite yourself today. 你今天看起来不大对劲。

  Do you have any money on you? 你身上带钱了吗?

  What is your major? 你学什么专业?

  My girlfriend and I broke up. 我和我的女朋友吹了。

  It was something that happens once in the blue moon. 这是千载难逢的事。

  I'll kick you out. 我将炒你鱿鱼

  I hate to be late and keep my date waiting. 我不喜欢迟到而让别人久等。

  There is nobody by that name working here. 这里没有这个人。

  He neither drinks nor smokes. 他既不喝酒也不抽烟。

  He pushes his luck. 他太贪心了。

  Nuts! 呸;胡说;混蛋!

  I can't make both ends meet. 我上个月接不到下个月,缺钱。

  It is of high quality. 它质量上乘。

  Dead end. 死胡同。

  Would you mind making less noise. 能不能小声点

Tuesday, June 03, 2008 2:06:39 PM UTC  #    Comments [0]    |  Trackback
Copyright © 2009 Kevin Mocha. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: