Click here to Skip to main content
15,885,546 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Math in XAML Pin
Pete O'Hanlon2-Aug-11 6:08
mvePete O'Hanlon2-Aug-11 6:08 
GeneralRe: Math in XAML Pin
Mc_Topaz2-Aug-11 6:40
Mc_Topaz2-Aug-11 6:40 
GeneralRe: Math in XAML Pin
SledgeHammer012-Aug-11 7:22
SledgeHammer012-Aug-11 7:22 
QuestionClient side validation Pin
yesu prakash1-Aug-11 20:14
yesu prakash1-Aug-11 20:14 
AnswerRe: Client side validation Pin
Mycroft Holmes4-Aug-11 13:07
professionalMycroft Holmes4-Aug-11 13:07 
QuestionDistance Calculate Of A Route Pin
mrhydn1-Aug-11 3:44
mrhydn1-Aug-11 3:44 
QuestionGrid in a combo box [modified] Pin
Lutosław31-Jul-11 2:57
Lutosław31-Jul-11 2:57 
AnswerRe: Grid in a combo box Pin
teejayem31-Jul-11 6:42
teejayem31-Jul-11 6:42 
From MSDN[^] - A ListBoxItem is a ContentControl, which means that it can contain a single object of any type (such as a string, an image, or a panel).

This means you can directly add any type of content you wish (like a grid).

Grid grid = new Grid();
grid.Children.Add(new TextBlock { Text = "Hello"});

listBox.Items.Add(grid);



Or you can use a grid in your ItemTemplate

<ListBox x:Name="listBox" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <Grid HorizontalAlignment="Stretch">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Column="0" Text="{Binding Property1}" FontWeight="{Binding Path=Property1, Converter={StaticResource fontWeightConverter}}" />
                <TextBlock Grid.Column="1" Text="{Binding Property2}" FontWeight="{Binding Path=Property2, Converter={StaticResource fontWeightConverter}}" />
                <TextBlock Grid.Column="2" Text="{Binding Property3}" FontWeight="{Binding Path=Property3, Converter={StaticResource fontWeightConverter}}" />
            </Grid>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>


listBox.ItemsSource = new MyClass[] {
    new MyClass { Property1 = "a1", Property2 = "a2", Property3 = "a3"},
    new MyClass { Property1 = "b1", Property2 = "b2", Property3 = "b3"},
    new MyClass { Property1 = "c1", Property2 = "c2", Property3 = "c3"},
};


and the FontWeightConverter

public class FontWeightConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        String item = value as String;
        if (item == null) return FontWeights.Normal;

        int index = int.Parse(item.Substring(1, 1));

        return index % 3 == 1 ? FontWeights.Bold : FontWeights.Normal;
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

Don't be overcome by evil, but overcome evil with good

GeneralRe: Grid in a combo box Pin
Lutosław1-Aug-11 13:14
Lutosław1-Aug-11 13:14 
GeneralRe: Grid in a combo box Pin
SledgeHammer011-Aug-11 14:05
SledgeHammer011-Aug-11 14:05 
GeneralRe: Grid in a combo box [solved] Pin
Lutosław1-Aug-11 22:57
Lutosław1-Aug-11 22:57 
GeneralRe: Grid in a combo box [solved] Pin
SledgeHammer012-Aug-11 7:20
SledgeHammer012-Aug-11 7:20 
GeneralRe: Grid in a combo box [solved] Pin
Lutosław2-Aug-11 8:52
Lutosław2-Aug-11 8:52 
GeneralRe: Grid in a combo box Pin
SledgeHammer011-Aug-11 14:05
SledgeHammer011-Aug-11 14:05 
QuestionBinding: Accept an empty string in enumeration [modified] Pin
Lutosław30-Jul-11 10:24
Lutosław30-Jul-11 10:24 
AnswerRe: Binding: Accept an empty string in enumeration Pin
teejayem30-Jul-11 12:23
teejayem30-Jul-11 12:23 
GeneralRe: Binding: Accept an empty string in enumeration Pin
Lutosław31-Jul-11 1:16
Lutosław31-Jul-11 1:16 
QuestionProblem with WPF and calling a WCF Web Service Pin
AndyCSharp29-Jul-11 5:54
AndyCSharp29-Jul-11 5:54 
AnswerRe: Problem with WPF and calling a WCF Web Service Pin
ToddHileHoffer29-Jul-11 7:46
ToddHileHoffer29-Jul-11 7:46 
QuestionListBox control with Button Items like apple iphone Pin
ISharda28-Jul-11 19:20
ISharda28-Jul-11 19:20 
QuestionAsynchronous Callback in WCF/Silverlight 4 application Pin
Parth Gandhi27-Jul-11 21:22
Parth Gandhi27-Jul-11 21:22 
AnswerRe: Asynchronous Callback in WCF/Silverlight 4 application Pin
Simon Bang Terkildsen27-Jul-11 23:24
Simon Bang Terkildsen27-Jul-11 23:24 
AnswerRe: Asynchronous Callback in WCF/Silverlight 4 application Pin
Abhinav S28-Jul-11 3:24
Abhinav S28-Jul-11 3:24 
QuestionCustom input for Silverlight DatePicker Pin
jadughar26-Jul-11 22:48
jadughar26-Jul-11 22:48 
AnswerRe: Custom input for Silverlight DatePicker Pin
Mycroft Holmes26-Jul-11 23:47
professionalMycroft Holmes26-Jul-11 23:47 

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.