VisualBrush is doesn't work
Hi,
VisualBrush is already supported, right?
https://www.noesisengine.com/docs/Gui.C ... Brush.html
I confirmed to exist VisualBrush.h/.cpp files.
The following code displays correctly in WPF, but noesis is not.
VisualBrush is already supported, right?
https://www.noesisengine.com/docs/Gui.C ... Brush.html
I confirmed to exist VisualBrush.h/.cpp files.
The following code displays correctly in WPF, but noesis is not.
Code: Select all
<Grid>
<Grid.Background>
<VisualBrush>
<VisualBrush.Visual>
<Grid>
<Label Background="Red">Red</Label>
</Grid>
</VisualBrush.Visual>
</VisualBrush>
</Grid.Background>
</Grid>
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: VisualBrush is doesn't work
Current implementation of VisualBrush in Noesis only allows to render visuals that are already in the UI tree (to generate duplicates, reflections, ...):
What do you want to achieve?
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#FF393C3E" Offset="0.2"/>
<GradientStop Color="#FF25282A" Offset="0.21"/>
<GradientStop Color="#FF485058" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<Viewbox Margin="100">
<Grid VerticalAlignment="Center" Margin="0,20,0,0">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid x:Name="Src" Width="500" Background="Transparent">
<Button Margin="16,0" Width="120" Padding="2,1" Content="Button 1" HorizontalAlignment="Center"/>
<Ellipse Fill="Red" Width="60" Height="60" Margin="100,0" HorizontalAlignment="Left" VerticalAlignment="Bottom"/>
</Grid>
<Rectangle Height="100" Grid.Row="1">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="0.5"/>
<SkewTransform AngleX="-30"/>
</TransformGroup>
</Rectangle.RenderTransform>
<Rectangle.Fill>
<VisualBrush Visual="{Binding ElementName=Src}">
<VisualBrush.RelativeTransform>
<ScaleTransform ScaleY="-1" CenterY="0.5"/>
</VisualBrush.RelativeTransform>
</VisualBrush>
</Rectangle.Fill>
<Rectangle.OpacityMask>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#40FFFFFF" Offset="0"/>
<GradientStop Color="#00FFFFFF" Offset="1"/>
</LinearGradientBrush>
</Rectangle.OpacityMask>
</Rectangle>
</Grid>
</Viewbox>
</Grid>
Re: VisualBrush is doesn't work
Thank you for your reply.
It define VisualBrush of icon image as resource.
The VisualBrush is use with other XAML.
ConverterSvgImageToBrush converts to VisualBrush from (string)SvgImageName by ResourceDictionary.
In Blend(c#), it converts to ImageBrush of PNG for not breaking designer view of Blend.
Icon images XAML is created from SVG files when build vcxproj. So, user doesn't know resource name(x:key) until that time. Therefore, it cannot use "{StaticResource SvgImage_1}".
It doesn't have to be a Brush, but I suggested this as a way to reuse SVG image resources without breaking Blend's designer.
Please let me know if there is any other way.
I try to reuse icon images of SVG(XAML) as resources.What do you want to achieve?
It define VisualBrush of icon image as resource.
Code: Select all
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<VisualBrush x:Key="SvgImage_1">
<VisualBrush.Visual>
<Grid>
<!-- SVG icon image -->
</Grid>
</VisualBrush.Visual>
</VisualBrush>
</ResourceDictionary>
Code: Select all
<Button Background="{Binding SvgImageName, Converter={StaticResource ConverterSvgImageToBrush}}"/>
In Blend(c#), it converts to ImageBrush of PNG for not breaking designer view of Blend.
Icon images XAML is created from SVG files when build vcxproj. So, user doesn't know resource name(x:key) until that time. Therefore, it cannot use "{StaticResource SvgImage_1}".
It doesn't have to be a Brush, but I suggested this as a way to reuse SVG image resources without breaking Blend's designer.
Please let me know if there is any other way.
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: VisualBrush is doesn't work
Are these icon images formed with several paths and strokes with different brushes and pens?
If icons can be represented as a single geometry with a single brush/pen you can probably use Geometry resources instead and use them to specify the Data property of a Path shape (using a binding and your converter to determine the final resource name).
If icons contain different geometries then you can define them as a ControlTemplate to reuse them as controls.
I talked about these options in this post: viewtopic.php?f=3&t=814&p=4480&hilit=co ... icon#p4446
If icons can be represented as a single geometry with a single brush/pen you can probably use Geometry resources instead and use them to specify the Data property of a Path shape (using a binding and your converter to determine the final resource name).
If icons contain different geometries then you can define them as a ControlTemplate to reuse them as controls.
I talked about these options in this post: viewtopic.php?f=3&t=814&p=4480&hilit=co ... icon#p4446
Re: VisualBrush is doesn't work
I decided to solve it using ControlTemplate.
Thank you very much!!
Thank you very much!!
Who is online
Users browsing this forum: Google [Bot] and 12 guests