Home Forums WPF controls Xceed DataGrid for WPF Image in combox

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #22782 |

    Hello,

    I want to place an image and name like what we have in SOLID FOUNDATION sample, but i am not getting result.

    This Is the template i am using for Combobox

    <DataTemplate x:Key=”employeeDataTemplate”>
    <StackPanel Orientation=”Horizontal”>
    <Image Source=”{Binding Photo}”
    Height=”32″
    VerticalAlignment=”Top”
    Margin=”1″/>
    <TextBlock>
    <TextBlock.Text>
    <Binding Path=”FirstName”/>
    </TextBlock.Text>
    </TextBlock>
    </StackPanel>
    </DataTemplate>

    This is the combo declaration
    <ComboBox BorderThickness=”1″
    Background=”Transparent”
    Foreground=”{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(TextElement.Foreground)}”
    Height=”42″
    VerticalContentAlignment=”Top”
    ItemsSource=”{Binding Source={x:Static Application.Current},Path=Employees}”
    ItemTemplate=”{StaticResource employeeDataTemplate}”>
    </ComboBox>

    And here is the datatable which i am binding to the Combobox

    DataTable dt = new DataTable();
    dt.Columns.Add(“Photo”);
    dt.Columns.Add(“FirstName”);

    System.Data.DataRow dr = dt.NewRow();
    Image img = new Image();
    BitmapImage bi = new BitmapImage(new Uri(“Calendar.bmp”,UriKind.Relative));
    img.Source = bi;
    dr[0] = img;
    dr[1] = “Suresh Katari”;
    dt.Rows.Add(dr);

    System.Data.DataRow dr1 = dt.NewRow();
    Image img1 = new Image();
    BitmapImage bi1 = new BitmapImage(new Uri(“Calendar.bmp”, UriKind.Relative));
    img1.Source = bi1;
    dr1[0] = img1;
    dr1[1] = “Murthy Katari”;
    dt.Rows.Add(dr1);
    _employees = dt;

    Please tell me the mistakes what i have done and provide the solution as early as possible

    thanks in advance

    Imported from legacy forums. Posted by Suresh (had 1946 views)

    User (Old forums)
    Member
    Post count: 23064

    I had problems with comboboxes and datasources in XAML.
    It is supposed to work, but it never did for me.
    so look at my findings for comboboxes.

    http://forums.xceed.com/forums/ShowPost.aspx?PostID=6115

    I think your problems is with the features in XAML not working like they should

    Imported from legacy forums. Posted by MiddleTommy (had 2785 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.