Problem when defining a Border style in Office2013

2 posts, 0 answers
  1. Patrick
    Patrick avatar
    372 posts
    Member since:
    Aug 2012

    Posted 06 Jan 2014 Link to this post

    Hello,
    create a new WPF application, add references to Telerik.Windows.Controls and Telerik.Windows.Themes.Office2013.

    Then, replace App.xaml with:
    <Application
      x:Class="WpfApplication1.App"
      StartupUri="MainWindow.xaml">
     
      <Application.Resources>
        <ResourceDictionary>
     
          <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/System.Windows.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.xaml"/>
          </ResourceDictionary.MergedDictionaries>
     
        <Style x:Name="MyBorderStyle" TargetType="Border">
          <Setter Property="BorderBrush"     Value="Black" />
          <Setter Property="BorderThickness" Value="1" />
        </Style>
     
        </ResourceDictionary>
      </Application.Resources>
     
    </Application>

    Replace MainWindow.xaml with:
    <Window
      x:Class="WpfApplication1.MainWindow"
      Title="MainWindow" Height="350" Width="525">
      <tk:RadListBox Margin="10">
        <tk:RadListBoxItem Content="One" />
        <tk:RadListBoxItem Content="Two" />
        <tk:RadListBoxItem Content="Three" />
      </tk:RadListBox>
    </Window>

    Run the application: the list box items have a black border around them, as defined in the border style. But that's wrong because this is not a default style, so it should not be applied in this case.

    Patrick
  2. Patrick
    Patrick avatar
    372 posts
    Member since:
    Aug 2012

    Posted 07 Jan 2014 Link to this post

    Hello,
    I found the solution: the style should be defined with x:Key and not x:Name.
    Patrick
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top