1

Im trying to bind a Syncfusion TaskBar to an ObservableCollection, and have a list of TaskBarItems. Using code-behind, items are added like this:

TaskBar taskBar = new TaskBar();
TaskBarItem taskBarItem1 = new TaskBarItem();
taskBarItem1.Header = "TaskBarItem1";
TextBlock textBlock1 = new TextBlock();
textBlock1.Text = "This TaskBar that have a TaskBarItem.";
taskBarItem1.Items.Add(textBlock1);          
taskBar.Items.Add(taskBarItem1);

This XAML:

<syncfusion:TaskBar Grid.Row="1"
                VerticalAlignment="Stretch"
                ItemsSource="{Binding Path=DataContext.Categories, RelativeSource={RelativeSource AncestorType=localV:MainWindow}}">
    <syncfusion:TaskBar.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Path=FirstName}"/>
        </DataTemplate>
    </syncfusion:TaskBar.ItemTemplate>
</syncfusion:TaskBar>

gives me a list of TaskBarItems, with Header showing FirstName, and nothing in the expandable area of any TaskBarItem. How can I make proper bindings/templates to see both Header and data in the expandable area?

1
  • Can you explain for what purpose you are using TaskBar control in your application? So we may have better idea to suggest solution based on it. Note: I work for Syncfusion. Commented Sep 22, 2017 at 5:07

1 Answer 1

1

I would expect you to be able to define an ItemContainerStyle or a ContentTemplate:

<syncfusion:TaskBar Grid.Row="1"
                VerticalAlignment="Stretch"
                ItemsSource="{Binding Path=DataContext.Categories, RelativeSource={RelativeSource AncestorType=localV:MainWindow}}">
    <syncfusion:TaskBar.ItemContainerStyle>
        <Style TargetType="syncfusion:TaskBarItem">
            <Setter Property="Header" Value="{Binding Path=FirstName}" />
            <Setter Property="Content">
                <Setter.Value>
                    <TextBlock>This TaskBar that have a TaskBarItem</TextBlock>
                </Setter.Value>
            </Setter>
        </Style>
    </syncfusion:TaskBar.ItemContainerStyle>
</syncfusion:TaskBar>
Sign up to request clarification or add additional context in comments.

1 Comment

It did half of the work, binding the Header. But TaskBarItem is not a Content control - it doesn't have 'Content' property, it uses Children instead. Is it possible to bind Children, without creating a DependencyProperty?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.