Setting window icon with resource

5 posts, 0 answers
  1. Gilbert van Veen
    Gilbert van Veen avatar
    68 posts
    Member since:
    Oct 2009

    Posted 30 Dec 2009 Link to this post

    I can't set the icon, based on a resource.

    The error tells my "Can't find resource key IconTemplate".

    This is my code:
    <telerikNavigation:RadWindow  
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
        xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
        xmlns:dataForm="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"   
        xmlns:localCommon="clr-namespace:GaSuite" 
        x:Class="GaSuite.Dep_EditWindow" 
        Width="400" Height="Auto" 
        mc:Ignorable="d" 
        Icon="/Images/department.png"                          
        IconTemplate="{StaticResource IconTemplate}"   
        >     
        <Grid x:Name="LayoutRoot" Background="White">  
            <Grid.Resources> 
                <localCommon:ExtConverter x:Key="StringToImageSourceConverter" /> 
                <DataTemplate x:Key="IconTemplate">  
                    <Image Source="{Binding Converter={StaticResource StringToImageSourceConverter}}" /> 
                </DataTemplate> 
            </Grid.Resources> 
            <Grid.ColumnDefinitions> 
                <ColumnDefinition Width="0.438*"/>  
                <ColumnDefinition Width="0.562*"/>  
            </Grid.ColumnDefinitions> 
              
            <Grid Margin="8,8,8,8" Grid.ColumnSpan="2" > 
                <Grid.ColumnDefinitions> 
                    <ColumnDefinition Width="150"></ColumnDefinition> 
                    <ColumnDefinition></ColumnDefinition>  
                </Grid.ColumnDefinitions> 
                <Grid.RowDefinitions> 
                    <RowDefinition Height="30"/>                  
                    <RowDefinition Height="30"/>  
                    <RowDefinition Height="30"/>  
                    <RowDefinition Height="30"/>                  
                    <RowDefinition Height="*"/>  
                </Grid.RowDefinitions> 
                  
                <TextBlock Grid.Row="1" Grid.Column="0" Text="Id" VerticalAlignment="Bottom"></TextBlock> 
                <TextBlock Grid.Row="2" Grid.Column="0" Text="Nummer" VerticalAlignment="Bottom"></TextBlock> 
                <TextBlock Grid.Row="3" Grid.Column="0" Text="Omschrijving" VerticalAlignment="Bottom"></TextBlock> 
                  
                <TextBox x:Name="Dep_Id" Grid.Row="1" Grid.Column="1" Text="{Binding Id}" AcceptsReturn="True" Width="150" IsEnabled="False" Height="25" Margin="0" HorizontalAlignment="Left" /> 
                <TextBox x:Name="Dep_Number" Grid.Row="2" Grid.Column="1" Text="{Binding Number, Mode=TwoWay}" AcceptsReturn="True" Width="150" Height="25" MaxLength="15" Margin="0" HorizontalAlignment="Left" /> 
                <TextBox x:Name="Dep_Description" Grid.Row="3" Grid.Column="1" Text="{Binding Description, Mode=TwoWay}" AcceptsReturn="True" Width="150" Height="25" MaxLength="50" Margin="0" HorizontalAlignment="Left" />          
                <Button x:Name="OKButton" Grid.Row="4" Grid.Column="1" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,8,101,19"/>  
                <Button x:Name="CancelButton" Grid.Row="4" Grid.Column="1" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,8,22,19"/>              
            </Grid> 
        </Grid> 
    </telerikNavigation:RadWindow> 

    I think I am missing something here.

    Hope someone helpes me out.
  2. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 30 Dec 2009 Link to this post

    Hi Gilbert,

     Could you please try to move the DataTemplate with x:Key set to IconTemplate to the resources of the RadWindow or set the IconTemplate property directly (without using resources).

    If you have further questions we will be happy to assist you.

    Best wishes,
    Miroslav Nedyalkov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Gilbert van Veen
    Gilbert van Veen avatar
    68 posts
    Member since:
    Oct 2009

    Posted 30 Dec 2009 Link to this post

    <telerikNavigation:RadWindow  
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
        xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
        xmlns:dataForm="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"   
        xmlns:localCommon="clr-namespace:GaSuite" 
        x:Class="GaSuite.Dep_EditWindow" 
        Width="400" Height="Auto" 
        mc:Ignorable="d" 
        Icon="/Images/department.png" 
        IconTemplate = "{StaticResource IconTemplate}" 
        > 
        <telerikNavigation:RadWindow.Resources> 
            <localCommon:ExtConverter x:Key="StringToImageSourceConverter" /> 
            <DataTemplate x:Key="IconTemplate">  
                <Image Source="{Binding Converter={StaticResource StringToImageSourceConverter}}" /> 
            </DataTemplate> 
        </telerikNavigation:RadWindow.Resources> 

    Maybe I don't understand it but the above wont work. I get the same error. How can I set the icontemplate directly?
  5. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 30 Dec 2009 Link to this post

    Hi Gilbert,

     This code should fix work correctly:

    <telerikNavigation:RadWindow 
        xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
        xmlns:dataForm="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
        xmlns:localCommon="clr-namespace:GaSuite"
        x:Class="GaSuite.Dep_EditWindow"
        Width="400" Height="Auto"
        mc:Ignorable="d"
        Icon="/Images/department.png"
        >
        <telerikNavigation:RadWindow.IconTemplate>
            <DataTemplate>
                <Image Source="{Binding Converter={StaticResource StringToImageSourceConverter}}" />
            </DataTemplate>
        </telerikNavigation:RadWindow.IconTemplate>
     
    </telerikNavigation:RadWindow>
    Hope this helps.

    Kind regards,
    Miroslav Nedyalkov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Gilbert van Veen
    Gilbert van Veen avatar
    68 posts
    Member since:
    Oct 2009

    Posted 30 Dec 2009 Link to this post

    Miroslav,

    You are a great!

    It works fine now.

    Thanks again.

Back to Top
DevCraft banner