Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • cmkessell
    Participant
    Post count: 3

    Hi,

    Is the above sample code complete (e.g. is the XAML part available)? I’m trying to get validation working with your propertygrid, and using the above code I’ve managed to detect errors but a red box is being drawn around the entire propertygrid rather than around the individual erroneous item(s).

    I suspect I haven’t configured the XAML correctly. For example, should the propertygrid’s Validation.Errors property be used in some way?

    Thanks

    cmkessell
    Participant
    Post count: 3

    If it helps, here is the XAML of my simple test program:

    
    <Window x:Class="AvalonDockTest.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
            xmlns:local="clr-namespace:AvalonDockTest"
            mc:Ignorable="d"
            Title="MainWindow" Height="350" Width="525">
    
        <DockPanel>
            <StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
                <Button Content="Save Layout" Click="SaveLayout_Click" Margin="5"/>
                <Button Content="Load Layout" Click="LoadLayout_Click" Margin="5"/>
                <Button Content="Hide Pane 1" Click="HidePane1_Click" Margin="5"/>
                <Button Content="Show Pane 1" Click="ShowPane1_Click" Margin="5"/>
                <Button Content="Hide Pane 2" Click="HidePane2_Click" Margin="5"/>
                <Button Content="Show Pane 2" Click="ShowPane2_Click" Margin="5"/>
            </StackPanel>
    
            <xcad:DockingManager x:Name="dockingManager">
                <xcad:LayoutRoot>
                    <xcad:LayoutPanel Orientation="Horizontal">
                        <xcad:LayoutAnchorablePane>
                            <xcad:LayoutAnchorable x:Name="Pane1" ContentId="Pane1" Title="Pane 1"/>
                        </xcad:LayoutAnchorablePane>
                        <xcad:LayoutAnchorablePane>
                            <xcad:LayoutAnchorable x:Name="Pane2" ContentId="Pane2" Title="Pane 2"/>
                        </xcad:LayoutAnchorablePane>
                    </xcad:LayoutPanel>
                </xcad:LayoutRoot>
            </xcad:DockingManager>
        </DockPanel>
    </Window>
    

    and here is the code behind:

    
    using System.Windows;
    using System.IO;
    using Xceed.Wpf.AvalonDock.Layout.Serialization;
    
    namespace AvalonDockTest
    {
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void SaveLayout_Click(object sender, RoutedEventArgs e)
            {
                var serializer = new XmlLayoutSerializer(dockingManager);
                using (var writer = new StreamWriter("avalonlayout.xml"))
                    serializer.Serialize(writer);
            }
    
            private void LoadLayout_Click(object sender, RoutedEventArgs e)
            {
                var serializer = new XmlLayoutSerializer(dockingManager);
                using (var reader = new StreamReader("avalonlayout.xml"))
                    serializer.Deserialize(reader);
            }
    
            private void HidePane1_Click(object sender, RoutedEventArgs e)
            {
                Pane1.Hide();
            }
    
            private void ShowPane1_Click(object sender, RoutedEventArgs e)
            {
                Pane1.Show();
            }
    
            private void HidePane2_Click(object sender, RoutedEventArgs e)
            {
                Pane2.Hide();
            }
    
            private void ShowPane2_Click(object sender, RoutedEventArgs e)
            {
                Pane2.Show();
            }
    
        }
    }
    

    When run it produces a window with some buttons and two docking panes. The buttons allow the panes to be displayed or hidden. The Save Layout and Load Layout buttons allow the layout to be saved and reloaded; when the layout it has been reloaded, however, the ability to hide and show panes no longer works.

Viewing 2 posts - 1 through 2 (of 2 total)