none
BindingExpression error

    Domanda

  • Not being a WPF or xaml developer can anyone tell me how to cure these errors:

    System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='-30' BindingExpression:Path=ActualHeight; DataItem='MMgrProductionView' (Name='productionView'); target element is 'GerberDataGrid' (Name='MMgrProductionDataGrid'); target property is 'MaxHeight' (type 'Double')

    System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='-30' BindingExpression:Path=ActualHeight; DataItem='MMgrDevelopmentView' (Name='developmentView'); target element is 'GerberDataGrid' (Name='MMgrDevelopmentDataGrid'); target property is 'MaxHeight' (type 'Double')

    <gta:GTControl
       x:Class="JaguarPDS.MMgrView"
       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"
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
       xmlns:gta="clr-namespace:JaguarPDS"
        mc:Ignorable="d" xmlns:p="clr-namespace:ResourcesLibrary.JaguarPDS;assembly=ResourcesLibrary"
       xmlns:controls="clr-namespace:CustomControls"
       d:DesignWidth="910" Height="Auto"  >
        <!--<ScrollViewer x:Name="scrollvwer" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" >-->
            <!--<StackPanel x:Uid="StackPanel_1" VerticalAlignment="Top" x:Name="stkpanelGrids" Orientation="Vertical" >-->
      
        <Grid x:Name="grid">
            <Grid.Resources>
        <Style x:Key="GridSplitterPreviewStyle">
                    <Setter Property="Control.Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <Rectangle Fill="#80000000"/>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
                <Style x:Key="GridSplitterStyle1" TargetType="{x:Type GridSplitter}">
                    <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                    <Setter Property="PreviewStyle" Value="{StaticResource GridSplitterPreviewStyle}"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type GridSplitter}">
                                <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
                                    <StackPanel Background="WhiteSmoke"  Width="30" Height="5" Orientation="Horizontal" HorizontalAlignment="Center">
                                        <Ellipse Height="2.875" Stroke="#666" StrokeThickness="2" Width="2.875" Margin="4,0,2,0"/>
                                        <Ellipse Height="2.875" Stroke="#666" StrokeThickness="2" Width="2.875" Margin="0,0,2,0"/>
                                        <Ellipse Height="2.875" Stroke="#666" StrokeThickness="2" Width="2.875" Margin="0,0,2,0"/>
                                        <Ellipse Height="2.875" Stroke="#666" StrokeThickness="2" Width="2.875" Margin="0,0,2,0"/>
                                        <Ellipse Height="2.875" Stroke="#666" StrokeThickness="2" Width="2.875" Margin="0,0,2,0"/>
                                    </StackPanel>
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Grid.Resources>
                <Grid.RowDefinitions>
                    <RowDefinition Height="25"/>
                    <RowDefinition MaxHeight="{Binding ElementName=grid, Path=ActualHeight}" MinHeight="32"/>
                    <RowDefinition MaxHeight="{Binding ElementName=grid, Path=ActualHeight}" MinHeight="32"/>
                    <RowDefinition MaxHeight="{Binding ElementName=grid, Path=ActualHeight}" MinHeight="32"/>
                    <RowDefinition MaxHeight="{Binding ElementName=grid, Path=ActualHeight}" MinHeight="32"/>
                    <RowDefinition MaxHeight="{Binding ElementName=grid, Path=ActualHeight}" MinHeight="32"/>
                </Grid.RowDefinitions>
               
                <!-- Model Manager Toolbar -->
                <gta:MMgrToolbarView x:Uid="vw:MMgrToolbarView_1" x:Name="toolbarview" Grid.Row="0"/>

                <!--Model Manager Production View -->
                <Expander Grid.Row="1"  Header="{x:Static p:Resources.ExpanderProduction}" Margin="0,0,0,5" IsExpanded="True" x:Name="One" BorderThickness="3" Collapsed="Collapsed"
                      MaxHeight="{Binding ElementName=grid, Path = RowDefinitions[1].MaxHeight}">
                        <gta:MMgrProductionView x:Uid="vw:MMgrProductionView_1" x:Name="productionView"  Margin="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
                    </Expander>
            <GridSplitter Margin="0,0,50,0" Style="{DynamicResource GridSplitterStyle1}" Height="5" Background="#FFBCBCBC" PreviewMouseLeftButtonDown="GridSplitter_PreviewMouseLeftButtonDown"  VerticalAlignment="Bottom" Grid.Row="1" HorizontalAlignment="Stretch" ></GridSplitter>
               
                    <!--Model Manager Development View -->
                <Expander Grid.Row="2" Header="{x:Static p:Resources.ExpanderDevelopment}" Margin="0,0,0,5" IsExpanded="True" x:Name="Two" BorderThickness="3" Collapsed="Collapsed"
                      MaxHeight="{Binding ElementName=grid, Path = RowDefinitions[2].MaxHeight}">
                    <gta:MMgrDevelopmentView  x:Uid="vw:MMgrDevelopmentView_1" x:Name="developmentView"  Margin="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
                    </Expander>

            <GridSplitter Margin="0,0,50,0" Style="{DynamicResource GridSplitterStyle1}" Height="5" Background="#FFBCBCBC" PreviewMouseLeftButtonDown="GridSplitter_PreviewMouseLeftButtonDown"  VerticalAlignment="Bottom" Grid.Row="2" HorizontalAlignment="Stretch" ></GridSplitter>
            <Expander Grid.Row="3" Header="{x:Static p:Resources.MMgrOptionsTitleBar}" Margin="0,0,0,5" IsExpanded="True" x:Name="Three" BorderThickness="3" Collapsed="Collapsed"
                      MaxHeight="{Binding ElementName=grid, Path = RowDefinitions[3].MaxHeight}">
                <gta:MMgrOptionViewExpanded  x:Uid="vw:MMgrOptionViewExpanded_1" x:Name="optionView"  Margin="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
            </Expander>

            <GridSplitter Margin="0,0,50,0" Style="{DynamicResource GridSplitterStyle1}" Height="5" Background="#FFBCBCBC" PreviewMouseLeftButtonDown="GridSplitter_PreviewMouseLeftButtonDown"  VerticalAlignment="Bottom" Grid.Row="3" HorizontalAlignment="Stretch" ></GridSplitter>


            <!--Model Manager Visualization Objects View -->
                <Expander Grid.Row="4" Header="{x:Static p:Resources.ExpanderVisualizationObjects}" Margin="0,0,0,5" IsExpanded="True" x:Name="Four" BorderThickness="3" Collapsed="Collapsed"
                      MaxHeight="{Binding ElementName=grid, Path = RowDefinitions[4].MaxHeight}">
                    <gta:MMgrVisualizationObjectsView x:Uid="vw:MMgrVisualizationObjectsView_1"  HorizontalAlignment="Stretch"/>
                    </Expander>

            <GridSplitter Margin="0,0,50,0" Style="{DynamicResource GridSplitterStyle1}" Height="5" Background="#FFBCBCBC" PreviewMouseLeftButtonDown="GridSplitter_PreviewMouseLeftButtonDown"  VerticalAlignment="Bottom" Grid.Row="4" HorizontalAlignment="Stretch" ></GridSplitter>


                    <!--Model Manager Visualization Layouts View -->
                <Expander Grid.Row="5" Header="{x:Static p:Resources.ExpanderLayout}" Margin="0,0,0,0" IsExpanded="True" x:Name="Five" BorderThickness="3" Collapsed="Collapsed"
                      MaxHeight="{Binding ElementName=grid, Path = RowDefinitions[5].MaxHeight}">
                            <gta:MMgrLayoutsView  x:Uid="vw:MMgrLayoutsView_1" x:Name="layoutView" Margin="0,0,0,10" />
                    </Expander>
            <GridSplitter Margin="0,0,50,0" Style="{DynamicResource GridSplitterStyle1}" x:Name="horizontalSplitter" Grid.ColumnSpan="5" ResizeDirection="Rows" ResizeBehavior="PreviousAndCurrent"  PreviewMouseLeftButtonDown="GridSplitter_PreviewMouseLeftButtonDown" Height="5" Visibility="Collapsed" Background="#FFBCBCBC"  VerticalAlignment="Bottom" Grid.Row="0" HorizontalAlignment="Stretch" ></GridSplitter>
              
            </Grid>

        <!--</StackPanel>-->
       <!--</ScrollViewer>-->      
    </gta:GTControl>

    Not sure if you need the code or can it all be done in the xaml.

    TIA

    martedì 1 maggio 2012 18:44

Risposte

  • Hi,

    The expression errors are cause by the following XAML as you are trying to bind the MaxHeight property to the ActualHeight property of the grid itself, which is yet to be determined during layout process. Simply removing the MaxHeight bindings from the row definition could fix it but not so sure the visual you are after.

          <Grid.RowDefinitions>
                     <RowDefinition Height="25"/>
                     <RowDefinition MaxHeight="{Binding ElementName=grid, Path=ActualHeight}" MinHeight="32"/>
                     <RowDefinition MaxHeight="{Binding ElementName=grid, Path=ActualHeight}" MinHeight="32"/>
                     <RowDefinition MaxHeight="{Binding ElementName=grid, Path=ActualHeight}" MinHeight="32"/>
                     <RowDefinition MaxHeight="{Binding ElementName=grid, Path=ActualHeight}" MinHeight="32"/>
                     <RowDefinition MaxHeight="{Binding ElementName=grid, Path=ActualHeight}" MinHeight="32"/>
                 </Grid.RowDefinitions>
     
    Regards,
    • Contrassegnato come risposta GSP_T mercoledì 2 maggio 2012 15:17
    martedì 1 maggio 2012 23:47