Application Resources

2 posts, 0 answers
  1. Zhang
    Zhang avatar
    4 posts
    Member since:
    Aug 2012

    Posted 18 Jul 2013 Link to this post

    hello
    I have builder  a Telerik project as below,but when running  it went wrong,the errorMessage(InnerException) is  "Unable to find the name "mystyle" resources. The resource name is case-sensitive.",How can I achieve this?
    thanks!
    //RadElips.xaml
    <telerik:RadWindow x:Class="WpfApplication1.RadElips"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
      Header="RadElips" Height="300" Width="300">
        <telerik:RadWindow.Resources>
            <!--<Style  x:Key="mystyle1" TargetType="{x:Type Control}" >
                <Setter Property="Background" Value="Black"></Setter>
                <Setter Property="Foreground" Value="WhiteSmoke"></Setter>
                <Setter Property="FontSize" Value="18"></Setter>
                <Style.Triggers>
                    <Trigger Property="IsMouseOver"  Value="True">
                        <Setter Property="Background" Value="Blue"></Setter>
                        <Setter Property="Foreground" Value="Green"></Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>-->
          
        </telerik:RadWindow.Resources>
        <Grid>
            <StackPanel>
                <Ellipse x:Name="elipse1" Stroke="Red" Height="120" Width="120"  StrokeThickness="6" Fill="Green"  ></Ellipse>
                <Button x:Name="btn01" Content="ok" Width="90" Height="38" Style="{StaticResource mystyle}"></Button>
            </StackPanel>
        </Grid>
    </telerik:RadWindow>
    //app.xaml
    <Application x:Class="WpfApplication1.App"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               >
        <Application.Resources>
            <Style x:Key="mystyle">
                <Setter Property="Control.Background" Value="Black"></Setter>
                <Setter Property="Control.Foreground" Value="White"></Setter>
            </Style>
        </Application.Resources>
    </Application>
    //app.xaml.cs
    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Windows;
    using Telerik.Windows.Controls;
    namespace WpfApplication1
    {
        /// <summary>
        /// App.xaml 的交互逻辑
        /// </summary>
        public partial class App : Application
        {
            public App()
            {
                StyleManager.ApplicationTheme = new Windows8Theme();
            }
            protected override void OnStartup(StartupEventArgs e)
            {
             //Telerik Window - RadElips
                RadElips   radelips= new RadElips();
                radelips.Show();
                base.OnStartup(e);
            }
        }
    }

  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 23 Jul 2013 Link to this post

    Hello Zhang,

    Please check our reply in the other forum thread regarding RadWindow and implicit styles:
    http://www.telerik.com/community/forums/wpf/general-discussions/show-radwindow-with-implict-style.aspx

    If you move the "mystyle" Style inside MainRadWindowDictionary.xaml the current issue should be fixed.

    Regards,
    Yana
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top