problem when bind image and header name

7 posts, 1 answers
  1. Dian
    Dian avatar
    16 posts
    Member since:
    Oct 2010

    Posted 28 Aug 2011 Link to this post

    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>

     

     

     

     

  2. Dian
    Dian avatar
    16 posts
    Member since:
    Oct 2010

    Posted 28 Aug 2011 Link to this post

    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>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 31 Aug 2011 Link to this post

    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 >>

  5. Dian
    Dian avatar
    16 posts
    Member since:
    Oct 2010

    Posted 31 Aug 2011 Link to this post

    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
  6. Michael
    Michael avatar
    23 posts
    Member since:
    Mar 2014

    Posted 27 Mar 2014 Link to this post

    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.
  7. Michael
    Michael avatar
    23 posts
    Member since:
    Mar 2014

    Posted 27 Mar 2014 in reply to Michael Link to this post

    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.
  8. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 28 Mar 2014 Link to this post

    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.

     
Back to Top
UI for WPF is Visual Studio 2017 Ready