This is a migrated thread and some comments may be shown as answers.

problem when bind image and header name

6 Answers 50 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Dian
Top achievements
Rank 1
Dian asked on 29 Aug 2011, 12:07 AM

Hi,

I had a separate radpane xaml class, it would dynamically generated radpane if it needs.

My problem is when I bound HeaderName to Header without HeaderTemplate code(where I commented), it is working fine to show headername only. But if I uncommented HeaderTemplate code, I only got image show in the UI, no text.
Below is my code:

<telerik:RadPane x:Class="TemplatorWPF.LoadSource" x:Name="RadPaneSource"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:local="clr-namespace:_ViewModel;assembly=_ViewModel"
             mc:Ignorable="d" Header="{Binding HeaderName}"
             d:DesignHeight="300" d:DesignWidth="300">
        <!--<telerik:RadPane.HeaderTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <Image Source="../Resources/templator - level 1.png" />
                    <TextBlock Text="{Binding HeaderName}"/>
                </StackPanel>
            </DataTemplate>
      </telerik:RadPane.HeaderTemplate>-->
    <telerik:RadPane.Resources>

 

 

 

 

6 Answers, 1 is accepted

Sort by
0
Dian
Top achievements
Rank 1
answered on 29 Aug 2011, 04:26 AM
Hi,
I found a way to fix it. 

Change
<TextBlock Text="{Binding HeaderName}"/>
 to

<TextBlock Text="{Binding }"/>.

Also it seems no matter when you use Title or Header, eg: Header="{Binding HeaderName}" or Title="{Binding HeaderName}", both work fine, but each time when I change it to other, it will generate a exception at first time.


I still need help, I also need bind image as well, it doesn't work.   
<telerik:RadPane x:Class="TemplatorWPF.LoadSource" x:Name="RadPaneSource"
  
  
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  
  
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
  
             xmlns:local="clr-namespace:_ViewModel;assembly=_ViewModel"
  
             mc:Ignorable="d" Header="{Binding HeaderName}"
  
             d:DesignHeight="300" d:DesignWidth="300">
  
        <telerik:RadPane.HeaderTemplate>
  
            <DataTemplate>
  
                <StackPanel Orientation="Horizontal">
  
                    <Image Source="{Binding HeaderImage}" />
  
                    <TextBlock Text="{Binding }"/>
  
                </StackPanel>
  
            </DataTemplate>
  
      </telerik:RadPane.HeaderTemplate>
  
    <telerik:RadPane.Resources>
0
Accepted
Miroslav Nedyalkov
Telerik team
answered on 31 Aug 2011, 08:45 AM
Hello Dian,

 What I would suggest you is to bind the Header to be the whole View-model and to turn back the the binding to be to the HeaderName property. The problem is that the HeaderTemplate has for its DataContext the value of the Header property so you will not be able to bind both the image and the text if you provide just one of the values.

Hope this helps.

Best wishes,
Miroslav Nedyalkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Dian
Top achievements
Rank 1
answered on 01 Sep 2011, 12:20 AM
Hi Miroslav,

Thanks for helping me.

I tried this then it work.

Header="{Binding HeaderName}" to Header="{Binding}"

and in headerTemplate 
<telerik:RadPane.HeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding HeaderImage}" />
<TextBlock Text="{Binding HeaderName}"/>
</StackPanel>
</DataTemplate>


Cheers,

Fendy
0
Michael
Top achievements
Rank 1
answered on 27 Mar 2014, 10:45 PM
Sorry for seeming dense.

I'm a bit new to docking. The basic concept I am fine with. The nuts and bolts I am a bit clumsy with yet.

I am "opening" a file for which I have a file view model established. I override ToString or the Header binding.

I create my new RadFilePane and set its DataContext. Then add it to a DocumentHost through AddPane.

Seemingly, so far so good, something is at least docking, or seems to. However, I get no Header showing, no images either, in spite of the binding to (I presume?) the view model Image property (an ImageSource).

When I figure it out, I'll know it that much better.

Thanks.

Best regards.
0
Michael
Top achievements
Rank 1
answered on 27 Mar 2014, 10:49 PM
Just ran a debug check. Definitely somethings not quite right in my view and/or view model. The string is not being called, nor is the Image getter.
0
Kalin
Telerik team
answered on 28 Mar 2014, 03:30 PM
Hello,

I can see we have opened another forum thread and I have already answered you there. Could please check my answer and I'll also ask you continue the conversation there.

Regards,
Kalin
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
Docking
Asked by
Dian
Top achievements
Rank 1
Answers by
Dian
Top achievements
Rank 1
Miroslav Nedyalkov
Telerik team
Michael
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or