Terje Isaksen Developer blog

2009-09-24 (Thursday)

WPF ComboBox and binding

Filed under: Developing — Terje Isaksen @ 12:26
Tags: , ,

XAML:

<Grid x:Name="xDetails" >
...
 <ComboBox x:Name="CurrencyCode" 
           SelectedValuePath="CurrencyId"   
           DisplayMemberPath="ISOCode"  
           SelectedValue="{Binding BaseCurrency.Id}" 
  />
...
 </Grid>

Code behind:

ICollection<Currency> CurrencyList; // object populated elsewhere
xObject CurrentObject; // object with one field called BaseCurrency
...
CurrencyCode.ItemsSource = CurrencyList;
xDetails.DataContext = CurrentObject;

xObject definition:

public partial class xObject : DtoBase
 {
...
 [DataMember]
 public IdDisplayValue BaseCurrency
...
}

IdDisplayValue definition:

[DataContract]
 [Serializable()]
 public class IdDisplayValue : DtoBase
 {
 ...
 [DataMember]
 public int Id
...
 [DataMember]
 public string DisplayValue
...
 }

Currency definition:

public partial class Currency : DtoBase
 {
...
 [DataMember]
 public int CurrencyId
...
 [DataMember]
 public string ISOCode
...
 }

2009-09-10 (Thursday)

WPF Closing child windows

Filed under: Developing — Terje Isaksen @ 14:12
Tags:

If you from a main window have opened some child windows, and want to close all windows when the main window closes, add this in APP.XML:

<Application x:Class="Client.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 StartupUri="MainWindow.xaml"
 ShutdownMode="OnMainWindowClose"         
 >

Hello world!

Filed under: Info — Terje Isaksen @ 13:53
Tags:

The purpose of this blog is to record any kind of tricks and techniques that I learn.

Create a free website or blog at WordPress.com.