WPF Datagrid in Control in Viewbox isn't responsive

Viewed 41

Application with an Dashboard. The Dashboard uses Cards in the form of User Controls. These Controls weren't responsive so I put them into Viewboxes. Some Cards are working but some don't. Especially the Cards with DataGrids in them don't work for me. Maybe you can help me out.

DashboardView

Here is the DashboardPage:

<Page x:Class="Keppler.MES.Common.Pages.Dashboard"
  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:sysglb="clr-namespace:System.Globalization;assembly=mscorlib"
  xmlns:local="clr-namespace:Keppler.MES.Common.Pages" 
  xmlns:pageviewmodels="clr-namespace:Keppler.ViewModels.PageViewModels;assembly=Keppler.ViewModels" xmlns:controls="clr-namespace:Keppler.MES.Common.Pages.Controls"
  mc:Ignorable="d" 
  Title="DashboardPage">
<Page.DataContext>
    <pageviewmodels:VMDashboard/>
</Page.DataContext>
<Page.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="..\Common\ResourceDictionaries\KepplerColorsAndBrushes.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Page.Resources>
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="7*"/>
        <ColumnDefinition Width="7*"/>
        <ColumnDefinition Width="7*"/>
        <ColumnDefinition Width="7*"/>
        <ColumnDefinition Width="7*"/>
        <ColumnDefinition Width="7*"/>
        <ColumnDefinition Width="7*"/>
        <ColumnDefinition Width="7*"/>
        <ColumnDefinition Width="7*"/>
        <ColumnDefinition Width="7*"/>
        <ColumnDefinition Width="7*"/>
        <ColumnDefinition Width="7*"/>

    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="35"/>
        <RowDefinition Height="10*"/>
        <RowDefinition Height="10*"/>
        <RowDefinition Height="10*"/>
        <RowDefinition Height="10*"/>
        <RowDefinition Height="10*"/>
        <RowDefinition Height="10*"/>
        <RowDefinition Height="10*"/>
        <RowDefinition Height="10*"/>
        <RowDefinition Height="10*"/>
        <RowDefinition Height="10*"/>
    </Grid.RowDefinitions>
    
      <controls:KepplerEffortCard PageName="Bookings" GroupedEfforts="{Binding EffortOfLastWorkDay}" EffortOfBindings="{Binding LastWorkDaysEffort}" JumpToLink="{Binding RequestPageChangeCommand}" Grid.Row="3" Grid.ColumnSpan="6" Grid.RowSpan="2"/>
   

     <controls:KepplerEffortCard PageName="Bookings" GroupedEfforts="{Binding EffortOfLastWeek}" EffortOfBindings="{Binding LastWeeksEffort}" JumpToLink="{Binding RequestPageChangeCommand}" Grid.Column="6" Grid.Row="3" Grid.ColumnSpan="6" Grid.RowSpan="2"/>

    <controls:KepplerOrdersCard PageName="Orders" Grid.ColumnSpan="12" Grid.Row="5" Grid.RowSpan="2" OrderBudgets="{Binding OrderBudgets}" JumpToLink="{Binding RequestPageChangeCommand}"/>
    <controls:KepplerTurnOverCard Grid.Row="0" Grid.ColumnSpan="2" Header="{Binding TurnOverThisYear.Header}" TurnOver="{Binding TurnOverThisYear.TurnOver}"  Grid.Column="0" Margin="10,0" />
    <controls:KepplerTurnOverCard Grid.Row="0" Header="{Binding TurnOverLastYear.Header}" TurnOver="{Binding TurnOverLastYear.TurnOver}"  Grid.Column="2" Grid.ColumnSpan="2" Margin="10,0" RenderTransformOrigin="0.5,0.5"/>
    <controls:KepplerTurnOverCard Grid.Row="0" Grid.ColumnSpan="2" Header="{Binding TurnOverThisQuarter.Header}" TurnOver="{Binding TurnOverThisQuarter.TurnOver}" Grid.Column="4" Margin="10,0"/>
    <controls:KepplerTurnOverCard Header="{Binding TurnOverThisMonth.Header}" TurnOver="{Binding TurnOverThisMonth.TurnOver}"  Grid.ColumnSpan="2" Grid.Column="6" Grid.Row="0" Margin="10,0"/>
    
    <Viewbox Grid.Row="1" Grid.Column="0" StretchDirection="Both" Stretch="Fill" Grid.ColumnSpan="2" Grid.RowSpan="2">
    <controls:KepplerWarningCard PageName="Orders" WarningsInfo="{Binding BudgetWarning}" JumpToLink="{Binding RequestPageChangeCommand}"/>
    </Viewbox>
    <Viewbox Grid.Row="1" Grid.Column="2" StretchDirection="Both" Stretch="Fill" Grid.ColumnSpan="2" Grid.RowSpan="2">
        <controls:KepplerWarningCard PageName="Invoices" WarningsInfo="{Binding InvoiceWarning}" JumpToLink="{Binding RequestPageChangeCommand}"/>
    </Viewbox>
    
    <Viewbox Grid.Row="1" Grid.Column="4" StretchDirection="Both" Stretch="Fill" Grid.ColumnSpan="2" Grid.RowSpan="2">
    <controls:KepplerWarningCard PageName="Orders" WarningsInfo="{Binding ResourceWarning}" JumpToLink="{Binding RequestPageChangeCommand}"/>
    </Viewbox>
    <Viewbox Grid.Row="1" Grid.Column="6" StretchDirection="Both" Stretch="Fill" Grid.ColumnSpan="2" Grid.RowSpan="2">
            <controls:KepplerWarningCard PageName="Orders" WarningsInfo="{Binding DeliveryWarning}" JumpToLink="{Binding RequestPageChangeCommand}"/>
        </Viewbox>
    
        <Viewbox Grid.Row="1" Grid.Column="8" StretchDirection="Both" Stretch="Fill" Grid.ColumnSpan="2" Grid.RowSpan="2">
                <controls:KepplerWarningCard PageName="Orders" WarningsInfo="{Binding WorkloadWarning}" JumpToLink="{Binding RequestPageChangeCommand}"/>
            </Viewbox>
            <Viewbox Grid.Row="1" Grid.Column="10" StretchDirection="Both" Stretch="Fill" Grid.ColumnSpan="2" Grid.RowSpan="2">
                    <controls:KepplerBankingCard BankingsInfo="{Binding BankingsInfo}"/>
                </Viewbox>
    
                <controls:KepplerCustomerCard PageName="Customers" Grid.Row="7" Grid.RowSpan="2" Customers="{Binding Customers}" Grid.ColumnSpan="12" JumpToLink="{Binding RequestPageChangeCommand}"/>
    <controls:KepplerProjectsCard PageName="Projects" Grid.ColumnSpan="12" Grid.Row="9" Grid.RowSpan="2" Projects="{Binding Projects}" JumpToLink="{Binding RequestPageChangeCommand}"/>


</Grid>

Here is the Control:

<UserControl x:Class="Keppler.MES.Common.Pages.Controls.KepplerOrdersCard"
         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:local="clr-namespace:Keppler.MES.Common.Pages.Controls"
         mc:Ignorable="d" 
         Name="OrderBudgetCard"
         d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="..\..\Common\ResourceDictionaries\KepplerColorsAndBrushes.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</UserControl.Resources>
<Border CornerRadius="5" Margin="5" BorderThickness="0">
    <Border.BitmapEffect>
        <DropShadowBitmapEffect/>
    </Border.BitmapEffect>
    <Grid>
        <Border x:Name="DBRounded" CornerRadius="5" BorderThickness="1" Background="#FF888888"/>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="25"/>
                <RowDefinition Height="1*"/>
            </Grid.RowDefinitions>
        <Border x:Name="Header" Grid.ColumnSpan="1" Grid.RowSpan="1" CornerRadius="5,5,0,0" BorderThickness="1">
            <Border.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFFFAE00" Offset="0"/>
                    <GradientStop Color="#FFFFC500" Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
        </Border>
            <Button Background="Transparent" Command="{Binding ElementName=OrderBudgetCard, Path=JumpToLink}" CommandParameter="{Binding ElementName=OrderBudgetCard, Path=PageName}" Grid.ColumnSpan="1" Grid.RowSpan="2">
                <Button.Template>
                    <ControlTemplate TargetType="Button">
                        <Border x:Name="border" Background="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"
                        BorderThickness="1" CornerRadius="5">
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="border" Property="BorderBrush" Value="#FFFFAE00"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <DataGrid x:Name="dgOrderBudgets" 
              Background="Transparent" 
              ItemsSource="{Binding ElementName=OrderBudgetCard, Path=OrderBudgets}" 
              AutoGenerateColumns="False"
              HorizontalGridLinesBrush="Transparent"
              VerticalGridLinesBrush="Transparent"
              BorderBrush="Transparent"
              IsReadOnly="True" Grid.RowSpan="2">

                <DataGrid.RowHeaderStyle>
                    <Style TargetType="DataGridRowHeader">
                        <Setter Property="Background" Value="Transparent"/>
                    </Style>
                </DataGrid.RowHeaderStyle>
                <DataGrid.ColumnHeaderStyle>
                    <Style TargetType="DataGridColumnHeader">
                        <Setter Property="Background" Value="Transparent"/>
                        <Setter Property="BorderBrush" Value="Transparent"/>
                        <Setter Property="BorderThickness" Value="0"/>
                        <Setter Property="FontSize" Value="16"/>
                        <Setter Property="FontWeight" Value="Bold"/>
                        <Setter Property="FontFamily" Value="Arial"/>
                        <Setter Property="Foreground" Value="White"/>
                        <Setter Property="Height" Value="auto"/>
                        <Setter Property="Margin" Value="5"/>
                    </Style>
                </DataGrid.ColumnHeaderStyle>

                <DataGrid.RowStyle>
                    <Style TargetType="DataGridRow">
                        <Setter Property="Background" Value="Transparent"/>
                        <Setter Property="BorderBrush" Value="Transparent"/>
                        <Setter Property="BorderThickness" Value="0"/>
                        <Setter Property="FontSize" Value="14"/>
                        <Setter Property="FontWeight" Value="Bold"/>
                        <Setter Property="FontFamily" Value="Arial"/>
                        <Setter Property="Foreground" Value="black"/>
                        <Style.Triggers>
                            <Trigger Property="IsSelected"
                    Value="True">
                                <Setter Property="BorderBrush" Value="Transparent" />
                                <Setter Property="Background" Value="Transparent" />
                                <Setter Property="BorderThickness" Value="0" />
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </DataGrid.RowStyle>
                <DataGrid.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Style.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Background" Value="Transparent" />
                                <Setter Property="BorderBrush" Value="Transparent" />
                                <Setter Property="Foreground" Value="darkred"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </DataGrid.CellStyle>
                <DataGrid.Columns>
                    <DataGridTextColumn Header="order number" Width="200" Binding="{Binding Order.Number}"/>
                    <DataGridTextColumn Header="budget [€]" Width="120" Binding="{Binding Order.Subtotal,StringFormat=C2, ConverterCulture=de-DE}"/>
                    <DataGridTextColumn Header="consumed [€]" Width="*" Binding="{Binding EffortInCash,StringFormat=C2, ConverterCulture=de-DE}"/>
                    <DataGridTextColumn Header="state" Width="*" Binding="{Binding Order.Title}"/>
                </DataGrid.Columns>

            </DataGrid>
            <Grid.OpacityMask>
            <VisualBrush Visual="{Binding ElementName=DBRounded}"/>
        </Grid.OpacityMask>
    </Grid>
    </Grid>
</Border>

I tried putting the other Controls into Viewboxes like the Warningcards, but I didnt get anything out of it. Doesnt matter if I used fill, uniform or uniformtofill.

0 Answers
Related