2

I'm trying to add little icons to my tabs in WPF but having trouble with how to set up the binding.

<TabItem.Header>
    <StackPanel Orientation="Horizontal">
          <Image Source="{Binding Source=prop:Resources.eye}" />
          <Label VerticalAlignment="Center">Header</Label>
    </StackPanel>
</TabItem.Header>

The xmlns:prop is set up for the local project's Properties, I am pulling other values from it elsewhere so I know that the namespace works. The markup above compiles fine BUT I don't see the eye image in the tab.

Also, is there any way to set this up into a template? I'm fairly new to XAML/WPF and each tab will have its own image...

1
  • You have what in Resources.eye ? Uri, file name, BitmapImage ? More details will help... Commented Apr 5, 2010 at 0:05

2 Answers 2

2

Use this code. It will work :)

<TabItem.Header>
    <StackPanel Orientation="Horizontal">
          <Image Source="{Binding Source={x:Static prop:Resources.eye}}" />
          <Label VerticalAlignment="Center">Header</Label>
    </StackPanel>
</TabItem.Header>
Sign up to request clarification or add additional context in comments.

Comments

1

Guessing without sufficient detail in your question, but you're setting the source of the binding to the string "prop:Resources.eye". What you want to do is resolve the string into the resource and assign that as the source:

<Image Source="{Binding Source={StaticResource prop:Resources.eye}}" />

Comments

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.