Render problem with "Grid.ColumnDefinitions" on runtime #235
Replies: 14 comments
|
@cemalgulbeyaz Normal WPF behavior of layout. You can either control the dimension with the |
|
@paulushub Thanks to you for information. Yes you are right if i set the Width and Height for Grid wich one cover the Image is works fine. But there is another situation now. I using this Grid in a UserControl and this user control size can change depending on manin view. I have tried to set Auto width and height ( already default value :) ) for Grid but it didn't work. I have to figure out this one now :) |
|
The question then is how do you want the The only time we try to restrict the size of the SharpVectors drawings is when rendering static image (bitmap), so the |
|
I downgraded to version 1.8.0 to get the previous behaviour. |
What behavior changed for you? |
|
@paulushub Ok i figured it by sertting MinWidth for CloumnDefination. Thanks for helping |
With 1.8.1 I do not see anymore SvgViewbox |
Sorry, I could not verify your issue. I have just tested the three Nuget packages
All show the SvgViewbox without any problem: |
|
SharpVectors.Wpf with .NET 4.7.2 with 1.8.0 visible, with 1.8.1 not <UserControl x:Class="Desktop.Views.DesktopViewNotification"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="http://prismlibrary.com/"
xmlns:gif="clr-namespace:XamlAnimatedGif;assembly=XamlAnimatedGif"
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
xmlns:infConverters="clr-namespace:Main.Infrastructure.Client.Converters;assembly=Main.Infrastructure.Client"
xmlns:custom="clr-namespace:OutlineText;assembly=OutlineTextControl"
prism:ViewModelLocator.AutoWireViewModel="True">
<UserControl.Resources>
<ResourceDictionary>
<infConverters:FactorConverter x:Key="FactorConverter" />
<infConverters:ToVisibilityConverter x:Key="ToVisibilityConverter" />
<infConverters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
<BooleanToVisibilityConverter x:Key="BoolToVis" />
<infConverters:StringToUpperConverter x:Key="StringToUpperConverter" />
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Main.Themes;component/MaterialDesign.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<prism:Dialog.WindowStyle>
<Style TargetType="Window" BasedOn="{StaticResource DefaultDialog}" />
</prism:Dialog.WindowStyle>
<Grid MinWidth="640" Width="{Binding Source={x:Static SystemParameters.PrimaryScreenWidth}, Converter={StaticResource FactorConverter}, ConverterParameter=0.75 }">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border CornerRadius="20,20,0,0" BorderThickness="10,10,10,0" BorderBrush="{DynamicResource PrimaryHueDarkBrush}" Background="{DynamicResource MaterialDesignPaper}" Margin="0,0,0,-3">
<Viewbox StretchDirection="Both">
<StackPanel>
<custom:OutlineTextControl HorizontalAlignment="Center" VerticalAlignment="Center" Margin="15,10,15,25"
FontFamily="Arial Black" FontSize="50" StrokeThickness="1" Bold="True"
Stroke="Black" Fill="{DynamicResource SecondaryHueMidBrush}"
Effect="{StaticResource OutlineDropShadowEffect}"
Text="{Binding Notification.WelcomeMessage, Converter={StaticResource StringToUpperConverter}}"
Visibility="{Binding Notification.WelcomeMessage, Converter={StaticResource ToVisibilityConverter}}"/>
<custom:OutlineTextControl HorizontalAlignment="Center" VerticalAlignment="Center" Margin="15,0,15,25"
FontFamily="Arial Black" FontSize="48" StrokeThickness="1" Bold="True"
Stroke="Black" Fill="{DynamicResource PrimaryHueDarkBrush}"
Effect="{StaticResource OutlineDropShadowEffect}"
Text="{Binding Notification.Title, Converter={StaticResource StringToUpperConverter}}"/>
<custom:OutlineTextControl HorizontalAlignment="Center" VerticalAlignment="Center" Margin="15,0,15,3"
FontFamily="Arial Black" FontSize="32" StrokeThickness="1" Bold="True"
Stroke="Black" Fill="{DynamicResource PrimaryHueLightBrush}"
Effect="{StaticResource OutlineDropShadowEffect}"
Text="{Binding Notification.Message, Converter={StaticResource StringToUpperConverter}}"/>
</StackPanel>
</Viewbox>
</Border>
<Border Grid.Row="1" CornerRadius="0,0,20,20" BorderThickness="10,0,10,10" BorderBrush="{DynamicResource PrimaryHueDarkBrush}" Background="{DynamicResource MaterialDesignPaper}" Height="400" MinWidth="600">
<Grid Margin="20 15 20 50">
<Image gif:AnimationBehavior.SourceUri="{Binding Notification.ImageUrl}" Stretch="None"
Visibility="{Binding Notification.ImageUrl, Converter={StaticResource ToVisibilityConverter}}" />
<svgc:SvgViewbox x:Name="SvgViewbox" Source="{Binding Notification.SvgUrl}" HorizontalAlignment="Center"
RenderTransformOrigin="0.5,0.5" Opacity="0.5"
Visibility="{Binding Notification.SvgUrl, Converter={StaticResource ToVisibilityConverter}}">
<svgc:SvgViewbox.RenderTransform>
<ScaleTransform x:Name="MyAnimatedScaleTransform" ScaleX="0.8" ScaleY="0.8"/>
</svgc:SvgViewbox.RenderTransform>
<svgc:SvgViewbox.Triggers>
<EventTrigger RoutedEvent="svgc:SvgViewbox.Loaded">
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever" AutoReverse="True">
<DoubleAnimation Storyboard.TargetName="MyAnimatedScaleTransform"
Storyboard.TargetProperty="ScaleX"
To="1.0" Duration="0:0:1" />
<DoubleAnimation Storyboard.TargetName="MyAnimatedScaleTransform"
Storyboard.TargetProperty="ScaleY"
To="1.0" Duration="0:0:1" />
<DoubleAnimation Storyboard.TargetName="SvgViewbox"
Storyboard.TargetProperty="Opacity"
To="1.0" Duration="0:0:1" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</svgc:SvgViewbox.Triggers>
</svgc:SvgViewbox>
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}" Value="0" IsIndeterminate="True"
Width="40" Height="40" Visibility="{Binding Notification.IsBusy, Converter={StaticResource BoolToVis}}">
<ProgressBar.LayoutTransform>
<ScaleTransform ScaleX="8" ScaleY="8"/>
</ProgressBar.LayoutTransform>
</ProgressBar>
</Grid>
</Border>
</Grid>
</UserControl> |
|
The following simple use in user-control works with the SharpVectors.Wpf, .NET 4.7.2 <UserControl x:Class="WpfApp11.UserControl1"
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:WpfApp11"
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<svgc:SvgViewbox Source="https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/rg1024_green_grapes.svg"
HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
</UserControl>I do not know what is falling in your codes. Can you name all the packages/versions in your code or post a sample project for testing? |
|
Please try https://github.com/GioviQ/SharpVectors.Wpf.1.8.1.bug |
@GioviQ Fix the source Uri. With 1.8.1 there are several improvements and fixes in the support for the Uri to make it work in both design mode and runtime. The Uri Also, SharpVectors adds support for assembly name with the |
|
Still I do not understand the need to remove the support to a valid URI just present in https://learn.microsoft.com/en-us/dotnet/desktop/wpf/app-development/pack-uris-in-wpf?view=netframeworkdesktop-4.8 |
Again, SharpVectors does not expect the Resource file in referenced assembly format. It worked in the 1.8.0 versions of the The updated Uri support in 1.8.1 did not break any samples in the SharpVectors, because all used the Resource file in local assembly format. If you wish to specify the referenced assembly name, SharpVectors provides AppName property for that. You can avoid all that by providing the Full pack URI instead of the Relative pack URI. In design mode, several possible scans and checks are made (WPF does not provide design time interfaces for controls), which is too expensive for runtime - loading all resources and checking for the existence like |

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I have using SharpVector library in my project (WPF Core) to showing SVG images and this is the my reference " < PackageReference Include="SharpVectors.Reloaded" Version="1.8.1" / > "
The problem is happening if i use the svg image in grid with column definations. SVG image is render and showing while desing time with column defination but if i go to debug and runtime, it doesn't render and show. Everyting works normal without column defination. I put the xaml codes and screenshots below
With Grid.ColumnDefinitions
Without Grid.ColumnDefinitions
Screenshot
All reactions