Quantcast
Channel: wpftoolkit Discussions Rss Feed
Viewing all articles
Browse latest Browse all 2157

New Post: Customise AvalonDock style

$
0
0
Thanks for the help.

Using your example I managed to change the colours. However, they don't dynamically change at run time. I have two resource dictionaries:
In ExpressionLight.xaml I have:
<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
  xmlns:avalonDock="http://schemas.xceed.com/wpf/xaml/avalondock">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Xceed.Wpf.AvalonDock;component/Themes/generic.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <!-- AvalonDock styles -->
    <Style x:Key="MyDocumentPaneControlStyle"
           TargetType="{x:Type avalonDock:LayoutDocumentPaneControl}"
           BasedOn="{StaticResource DocumentPaneControlStyle}">
        <Setter Property="Background"
                Value="Blue"/>
    </Style>
In ExpressionDark.xaml I have
<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
  xmlns:avalonDock="http://schemas.xceed.com/wpf/xaml/avalondock"
  
  xmlns:avalonDockControls="clr-namespace:Xceed.Wpf.AvalonDock.Controls;assembly=Xceed.Wpf.AvalonDock"
  xmlns:avalonDockConverters="clr-namespace:Xceed.Wpf.AvalonDock.Converters;assembly=Xceed.Wpf.AvalonDock"
  >
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Xceed.Wpf.AvalonDock;component/Themes/generic.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <!-- AvalonDock styles -->
    <Style x:Key="MyDocumentPaneControlStyle"
           TargetType="{x:Type avalonDock:LayoutDocumentPaneControl}"
           BasedOn="{StaticResource DocumentPaneControlStyle}">
        <Setter Property="Background"
                Value="Red"/>
    </Style>
Then in my main code I have:
    Private Sub UIResourceChange(ByVal InterfaceColour As Integer)
     
        Dim fileName As String
        Dim dic As ResourceDictionary = Nothing

        If InterfaceColour = 1 Then
            fileName = System.Windows.Forms.Application.StartupPath + "\Resources\ExpressionLight.xaml"
        Else
            fileName = System.Windows.Forms.Application.StartupPath + "\Resources\ExpressionDark.xaml"
        End If
        Application.Current.Resources.MergedDictionaries.Clear()

        Using fs As IO.FileStream = New IO.FileStream(fileName, IO.FileMode.Open)

            dic = CType(Markup.XamlReader.Load(fs), ResourceDictionary)

            Application.Current.Resources.MergedDictionaries.Add(dic)
        End Using

       
    End Sub
The colours will load correctly on start up but won't change during runtime as InterfaceColour changes. Any ideas what I am doing wrong?

Thanks for any help.

Viewing all articles
Browse latest Browse all 2157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>