Click here to Skip to main content
15,886,199 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Using C# dependency property in XAML Triggers Pin
George Nistor15-Mar-12 23:29
George Nistor15-Mar-12 23:29 
GeneralRe: Using C# dependency property in XAML Triggers Pin
Prasoon Chaudhary15-Mar-12 23:40
Prasoon Chaudhary15-Mar-12 23:40 
QuestionWhat Does This Do? Pin
Kevin Marois13-Mar-12 12:53
professionalKevin Marois13-Mar-12 12:53 
AnswerRe: What Does This Do? Pin
Abhinav S14-Mar-12 20:13
Abhinav S14-Mar-12 20:13 
QuestionWhat's the best control for ..... Pin
Sutton Mehaffey13-Mar-12 11:34
Sutton Mehaffey13-Mar-12 11:34 
AnswerRe: What's the best control for ..... Pin
Pete O'Hanlon13-Mar-12 11:41
mvePete O'Hanlon13-Mar-12 11:41 
GeneralRe: What's the best control for ..... Pin
Sutton Mehaffey14-Mar-12 3:27
Sutton Mehaffey14-Mar-12 3:27 
GeneralRe: What's the best control for ..... Pin
Pete O'Hanlon14-Mar-12 5:24
mvePete O'Hanlon14-Mar-12 5:24 
I think you're misunderstanding me here. Imagine you have the following
C#
public class EmailItem : INotifyPropertyChanged
{
  public event PropertyChangedEventHandler PropertyChanged;
  private string emailAddress;
  private int emailCount;

  public string EmailAddress
  {
    get { return emailAddress; }
    set
    {
      if (emailAddress == value) return;
      emailAddress = value;
      NotifyPropertyChanged("EmailAddress");
    }
  }

  public int EmailCount
  {
    get { return emailCount; }
    set
    {
      if (emailCount== value) return;
      emailCount = value;
      NotifyPropertyChanged("EmailCount");
    }
  }

  private void NotifyPropertyChanged(string property)
  {
    PropertyChangedEventHandler handler = PropertyChanged;
    if (handler == null) return;
    handler(this, new PropertyChangedEventArgs(property));
  }
}

public class Emails
{
  public Emails()
  {  
    EmailList = new ObservableCollection<EmailList>();
  }
  public ObservableCollection<EmailList> EmailList { get; set; }
  // Populate the list with a few emails....
}
Now, in your XAML, you bind your ListBox to the EmailList collection via the ItemSource. Finally, you set up an ItemTemplate for the ListBox.
XML
<DataTemplate x:Key="emailsTemplate">
  <Grid>
    <Grid.ColumnDefinition>
      <ColumnDefinition Width="180" />
      <ColumnDefinition />
    </Grid.ColumnDefinition>
    <TextBlock Text="{Binding EmailCount}" Grid.Column="0" />
    <TextBox Text="{Binding EmailAddress}" Grid.Column="1" />
  </Grid>
</DataTemplate>
I've just knocked this together in the CP post editor, so there may be some rough edges, but you should get the idea.

*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

"Mind bleach! Send me mind bleach!" - Nagy Vilmos


My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility


GeneralRe: What's the best control for ..... Pin
Sutton Mehaffey14-Mar-12 6:58
Sutton Mehaffey14-Mar-12 6:58 
GeneralRe: What's the best control for ..... Pin
Pete O'Hanlon14-Mar-12 7:02
mvePete O'Hanlon14-Mar-12 7:02 
GeneralRe: What's the best control for ..... Pin
Sutton Mehaffey14-Mar-12 10:12
Sutton Mehaffey14-Mar-12 10:12 
GeneralRe: What's the best control for ..... Pin
Pete O'Hanlon14-Mar-12 10:25
mvePete O'Hanlon14-Mar-12 10:25 
GeneralRe: What's the best control for ..... Pin
Sutton Mehaffey14-Mar-12 10:44
Sutton Mehaffey14-Mar-12 10:44 
GeneralRe: What's the best control for ..... Pin
Pete O'Hanlon14-Mar-12 10:50
mvePete O'Hanlon14-Mar-12 10:50 
GeneralRe: What's the best control for ..... Pin
Sutton Mehaffey21-Mar-12 18:52
Sutton Mehaffey21-Mar-12 18:52 
QuestionFlip page animation.Again. Pin
demolexpert13-Mar-12 7:40
demolexpert13-Mar-12 7:40 
Questionunable to access parent property from a Trigger Pin
George Nistor13-Mar-12 7:15
George Nistor13-Mar-12 7:15 
QuestionBinding Fill property to value of node with particular id in XML Pin
Mahesha99912-Mar-12 21:32
Mahesha99912-Mar-12 21:32 
Questioninteraction between Models in PRISM V4 (WPF) Pin
radhwane12-Mar-12 13:09
radhwane12-Mar-12 13:09 
Questiondefining a grid row within a grid column, wpf, c# Pin
Sutton Mehaffey12-Mar-12 3:37
Sutton Mehaffey12-Mar-12 3:37 
AnswerRe: defining a grid row within a grid column, wpf, c# Pin
Pete O'Hanlon12-Mar-12 3:42
mvePete O'Hanlon12-Mar-12 3:42 
GeneralRe: defining a grid row within a grid column, wpf, c# Pin
Sutton Mehaffey12-Mar-12 4:50
Sutton Mehaffey12-Mar-12 4:50 
GeneralRe: defining a grid row within a grid column, wpf, c# Pin
Sutton Mehaffey12-Mar-12 4:51
Sutton Mehaffey12-Mar-12 4:51 
GeneralRe: defining a grid row within a grid column, wpf, c# Pin
Sutton Mehaffey12-Mar-12 4:52
Sutton Mehaffey12-Mar-12 4:52 
GeneralRe: defining a grid row within a grid column, wpf, c# Pin
Pete O'Hanlon12-Mar-12 4:59
mvePete O'Hanlon12-Mar-12 4:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.