View Issue Details

IDProjectCategoryView StatusLast Update
0000250NoesisGUIUnitypublic2018-11-23 11:08
Reporterai_enabled Assigned Tosfernandez  
PrioritylowSeveritymajor 
Status assignedResolutionopen 
Summary0000250: VisualBrush won't shown
Description

I attached example XAML, which works in Kaxaml.

Steps To Reproduce

<!-- This example shows how to use a VisualBrush to paint shapes and controls.
The code behind file, PaintingWithImages.xaml.cs, contains a default
constructor that initializes the markup defined here. -->
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

<StackPanel>

<StackPanel.Background>
  <VisualBrush Opacity="0.1" Viewport="0,0,250,30" ViewportUnits="Absolute" TileMode="Tile" Stretch="None">
    <VisualBrush.Visual>
      <Border Width="250" Background="Transparent">
        <TextBlock Margin="5" FontFamily="Palatino Linotype" FontSize="20px" >
          Painting with VisualBrush
          <TextBlock.Foreground>
            <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
              <LinearGradientBrush.GradientStops>
                <GradientStop Offset="0.0" Color="Black" />
                <GradientStop Offset="1.0" Color="Blue" />
              </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
          </TextBlock.Foreground>
        </TextBlock>
      </Border>
    </VisualBrush.Visual>
    <VisualBrush.RelativeTransform>
      <RotateTransform Angle="0" CenterX="0.5" CenterY="0.5" />
    </VisualBrush.RelativeTransform>
  </VisualBrush>
</StackPanel.Background>

<TextBlock Name="test"></TextBlock>
<Border Margin="0,10,0,30"
  BorderBrush="Black" BorderThickness="1" >
  <Border.Background>
    <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
      <LinearGradientBrush.GradientStops>
        <GradientStop Offset="0.0" Color="#CCCCFF" />
        <GradientStop Offset="1.0" Color="Transparent" />
      </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
  </Border.Background>

  <TextBlock Margin="10">
    <Bold>Painting with a VisualBrush</Bold><LineBreak/><LineBreak/>
    A VisualBrush can be used to paint areas with text, shapes, controls, and more.
  </TextBlock>
</Border>

<StackPanel Orientation="Horizontal" Margin="10" Background="White" HorizontalAlignment="Left">
  <Rectangle Width="150" Height="150" Stroke="Black" Margin="0,0,5,0">
    <Rectangle.Fill>
      <VisualBrush Viewport="0,0,95,35" ViewportUnits="Absolute" TileMode="Tile">
        <VisualBrush.Visual>
          <StackPanel Background="Transparent">
            <TextBlock FontSize="10pt" Margin="10">Hello, World!</TextBlock>
          </StackPanel>
        </VisualBrush.Visual>
      </VisualBrush>
    </Rectangle.Fill>
  </Rectangle>

  <Rectangle Width="150" Height="150" Stroke="Black" Margin="5,0,5,0">
    <Rectangle.Fill>
      <VisualBrush>
        <VisualBrush.Visual>
          <StackPanel Background="Transparent">
            <TextBlock FontSize="10pt" Margin="10">Hello, World!</TextBlock>
          </StackPanel>
        </VisualBrush.Visual>
      </VisualBrush>
    </Rectangle.Fill>
  </Rectangle>

  <Rectangle Width="150" Height="150" Stroke="Black" Margin="5,0,0,0">
    <Rectangle.Fill>
      <VisualBrush Viewport="0,0,95,35" ViewportUnits="Absolute" TileMode="Tile">
        <VisualBrush.Visual>
          <StackPanel Background="Transparent">
            <TextBlock FontSize="10pt" Margin="10">Hello, World!</TextBlock>
          </StackPanel>
        </VisualBrush.Visual>
        <VisualBrush.RelativeTransform>
          <RotateTransform Angle="45" CenterX="0.5" CenterY="0.5" />
        </VisualBrush.RelativeTransform>
      </VisualBrush>
    </Rectangle.Fill>
  </Rectangle>
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="10" Background="White" HorizontalAlignment="Left">
  <Rectangle Width="150" Height="150" Stroke="Black" Margin="0,0,5,0">
    <Rectangle.Fill>
      <VisualBrush Viewport="0,0,50,50" ViewportUnits="Absolute" TileMode="Tile">
        <VisualBrush.Visual>
          <StackPanel Background="Transparent">
            <Rectangle Width="25" Height="25" Fill="Red" Margin="2" />
            <TextBlock FontSize="10pt" Margin="2">Hello, World!</TextBlock>
            <Button Margin="2">A Button</Button>
          </StackPanel>
        </VisualBrush.Visual>
      </VisualBrush>
    </Rectangle.Fill>
  </Rectangle>

  <Rectangle Width="150" Height="150" Stroke="Black" Margin="5,0,5,0">
    <Rectangle.Fill>
      <VisualBrush>
        <VisualBrush.Visual>
          <StackPanel Background="Transparent">
            <Rectangle Width="25" Height="25" Fill="Red" Margin="2" />
            <TextBlock FontSize="10pt" Margin="2">Hello, World!</TextBlock>
            <Button Margin="2">A Button</Button>
          </StackPanel>
        </VisualBrush.Visual>
      </VisualBrush>
    </Rectangle.Fill>
  </Rectangle>

  <Rectangle Width="150" Height="150" Stroke="Black" Margin="5,0,0,0">
    <Rectangle.Fill>
      <VisualBrush Viewport="0,0,50,50" ViewportUnits="Absolute" TileMode="Tile">
        <VisualBrush.Visual>
          <StackPanel Background="Transparent">
            <Rectangle Width="25" Height="25" Fill="Red" Margin="2" />
            <TextBlock FontSize="10pt" Margin="2">Hello, World!</TextBlock>
            <Button Margin="2">A Button</Button>
          </StackPanel>
        </VisualBrush.Visual>
        <VisualBrush.RelativeTransform>
          <RotateTransform Angle="45" CenterX="0.5" CenterY="0.5" />
        </VisualBrush.RelativeTransform>
      </VisualBrush>
    </Rectangle.Fill>
  </Rectangle>
</StackPanel>

</StackPanel>
</UserControl>

PlatformAny

Activities

sfernandez

sfernandez

2013-08-29 10:57

manager   ~0000708

Our current VisualBrush implementation only works when VisualBrush.Visual refers to a Visual in the logical tree, for example:

<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<StackPanel VerticalAlignment="Center" Width="400">
    <StackPanel x:Name="Source" Orientation="Horizontal">
        <TextBlock Text="Hello World" Margin="2"/>
        <Button Content="A button" Margin="2"/>
        <Rectangle Width="100" Fill="Red" Margin="2"/>
    </StackPanel>
    <Rectangle Stroke="Black" Height="100" Margin="0,10">
        <Rectangle.Fill>
            <VisualBrush Visual="{Binding ElementName=Source}" Stretch="Uniform"/>
        </Rectangle.Fill>
    </Rectangle>
</StackPanel>

</Grid>

We will create a ticket in our feature request database to support inline definition of the VisualBrush.Visual property.

Do you need this feature right now?

ai_enabled

ai_enabled

2013-08-29 11:02

updater   ~0000709

I need VisualBrush or DrawingGeometry, without it I can't skin some controls. For example, I want to make health bar with small gradation rectangles. I have a XAML for it and it works good in WPF, but I can't port it to NoesisGUI. We decide not to use bitmap images for this, because our UI must be 100% vector-based and scalable.

sfernandez

sfernandez

2013-08-29 11:17

manager   ~0000710

Could you please paste here that health bar code to try figure out how to do it with current implemented features?

ai_enabled

ai_enabled

2013-08-29 12:32

updater   ~0000711

I need to implement bar like this: http://screencloud.net/v/EAzn

I have implemented bar this way:

<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid.Resources>
<Geometry x:Key="BarBrushPath">F1M200,2C200,2 207,2 207,2 207,2 220,15 220,15 220,15 213,15 213,15 213,15 200,2 200,2z M191,2C191,2 198,2 198,2 198,2 211,15 211,15 211,15 204,15 204,15 204,15 191,2 191,2z M182,2C182,2 189,2 189,2 189,2 202,15 202,15 202,15 195,15 195,15 195,15 182,2 182,2z M173,2C173,2 180,2 180,2 180,2 193,15 193,15 193,15 186,15 186,15 186,15 173,2 173,2z M164,2C164,2 171,2 171,2 171,2 184,15 184,15 184,15 177,15 177,15 177,15 164,2 164,2z M155,2C155,2 162,2 162,2 162,2 175,15 175,15 175,15 168,15 168,15 168,15 155,2 155,2z M146,2C146,2 153,2 153,2 153,2 166,15 166,15 166,15 159,15 159,15 159,15 146,2 146,2z M137,2C137,2 144,2 144,2 144,2 157,15 157,15 157,15 150,15 150,15 150,15 137,2 137,2z M128,2C128,2 128.438,2 129.094,2 131.062,2 135,2 135,2 135,2 148,15 148,15 148,15 141,15 141,15 141,15 128,2 128,2z M119,2C119,2 119.438,2 120.094,2 122.062,2 126,2 126,2 126,2 139,15 139,15 139,15 132,15 132,15 132,15 119,2 119,2z M110,2C110,2 110.438,2 111.094,2 113.062,2 117,2 117,2 117,2 130,15 130,15 130,15 123,15 123,15 123,15 110,2 110,2z M101,2C101,2 101.438,2 102.094,2 104.062,2 108,2 108,2 108,2 121,15 121,15 121,15 114,15 114,15 114,15 101,2 101,2z M92,2C92,2 92.438,2 93.094,2 95.062,2 99,2 99,2 99,2 112,15 112,15 112,15 105,15 105,15 105,15 92,2 92,2z M83,2C83,2 83.438,2 84.094,2 86.062,2 90,2 90,2 90,2 103,15 103,15 103,15 96,15 96,15 96,15 83,2 83,2z M74,2C74,2 74.438,2 75.094,2 77.062,2 81,2 81,2 81,2 94,15 94,15 94,15 87,15 87,15 87,15 74,2 74,2z M65,2C65,2 65.438,2 66.094,2 68.062,2 72,2 72,2 72,2 85,15 85,15 85,15 78,15 78,15 78,15 65,2 65,2z M56,2C56,2 56.438,2 57.094,2 59.062,2 63,2 63,2 63,2 76,15 76,15 76,15 69,15 69,15 69,15 56,2 56,2z M47,2C47,2 47.438,2 48.094,2 50.062,2 54,2 54,2 54,2 67,15 67,15 67,15 60,15 60,15 60,15 47,2 47,2z M38,2C38,2 45,2 45,2 45,2 58,15 58,15 58,15 51,15 51,15 51,15 38,2 38,2z M29,2C29,2 36,2 36,2 36,2 49,15 49,15 49,15 42,15 42,15 42,15 29,2 29,2z M20,2C20,2 27,2 27,2 27,2 40,15 40,15 40,15 33,15 33,15 33,15 20,2 20,2z M11,2C11,2 18,2 18,2 18,2 31,15 31,15 31,15 24,15 24,15 24,15 11,2 11,2z M2,2C2,2 9,2 9,2 9,2 22,15 22,15 22,15 15,15 15,15 15,15 2,2 2,2z</Geometry>
<VisualBrush x:Key="BarBrush">
<VisualBrush.Visual>
<Path Fill="#00b8fc" Data="{StaticResource BarBrushPath}" />
</VisualBrush.Visual>
</VisualBrush>
</Grid.Resources>

<Rectangle x:Name="ValueDisplay" HorizontalAlignment="Left"
Margin="0" Canvas.Left="1" Canvas.Top="4"
Fill="{StaticResource BarBrush}" Width="221" MaxWidth="221"
Height="13" MaxHeight="13">
<Rectangle.Clip>
<RectangleGeometry x:Name="ValueDisplayClip" Rect="0,0,221,13" />
</Rectangle.Clip>
</Rectangle>
</Grid>

<!-- Displayed value controled by setting Rect for the ValueDisplayClip. -->

sfernandez

sfernandez

2013-08-29 13:06

manager   ~0000712

The following should work with the same results:

<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Grid.Resources>
    <Geometry x:Key="BarBrushPath">F1M200,2C200,2 207,2 207,2 207,2 220,15 220,15 220,15 213,15 213,15 213,15 200,2 200,2z M191,2C191,2 198,2 198,2 198,2 211,15 211,15 211,15 204,15 204,15 204,15 191,2 191,2z M182,2C182,2 189,2 189,2 189,2 202,15 202,15 202,15 195,15 195,15 195,15 182,2 182,2z M173,2C173,2 180,2 180,2 180,2 193,15 193,15 193,15 186,15 186,15 186,15 173,2 173,2z M164,2C164,2 171,2 171,2 171,2 184,15 184,15 184,15 177,15 177,15 177,15 164,2 164,2z M155,2C155,2 162,2 162,2 162,2 175,15 175,15 175,15 168,15 168,15 168,15 155,2 155,2z M146,2C146,2 153,2 153,2 153,2 166,15 166,15 166,15 159,15 159,15 159,15 146,2 146,2z M137,2C137,2 144,2 144,2 144,2 157,15 157,15 157,15 150,15 150,15 150,15 137,2 137,2z M128,2C128,2 128.438,2 129.094,2 131.062,2 135,2 135,2 135,2 148,15 148,15 148,15 141,15 141,15 141,15 128,2 128,2z M119,2C119,2 119.438,2 120.094,2 122.062,2 126,2 126,2 126,2 139,15 139,15 139,15 132,15 132,15 132,15 119,2 119,2z M110,2C110,2 110.438,2 111.094,2 113.062,2 117,2 117,2 117,2 130,15 130,15 130,15 123,15 123,15 123,15 110,2 110,2z M101,2C101,2 101.438,2 102.094,2 104.062,2 108,2 108,2 108,2 121,15 121,15 121,15 114,15 114,15 114,15 101,2 101,2z M92,2C92,2 92.438,2 93.094,2 95.062,2 99,2 99,2 99,2 112,15 112,15 112,15 105,15 105,15 105,15 92,2 92,2z M83,2C83,2 83.438,2 84.094,2 86.062,2 90,2 90,2 90,2 103,15 103,15 103,15 96,15 96,15 96,15 83,2 83,2z M74,2C74,2 74.438,2 75.094,2 77.062,2 81,2 81,2 81,2 94,15 94,15 94,15 87,15 87,15 87,15 74,2 74,2z M65,2C65,2 65.438,2 66.094,2 68.062,2 72,2 72,2 72,2 85,15 85,15 85,15 78,15 78,15 78,15 65,2 65,2z M56,2C56,2 56.438,2 57.094,2 59.062,2 63,2 63,2 63,2 76,15 76,15 76,15 69,15 69,15 69,15 56,2 56,2z M47,2C47,2 47.438,2 48.094,2 50.062,2 54,2 54,2 54,2 67,15 67,15 67,15 60,15 60,15 60,15 47,2 47,2z M38,2C38,2 45,2 45,2 45,2 58,15 58,15 58,15 51,15 51,15 51,15 38,2 38,2z M29,2C29,2 36,2 36,2 36,2 49,15 49,15 49,15 42,15 42,15 42,15 29,2 29,2z M20,2C20,2 27,2 27,2 27,2 40,15 40,15 40,15 33,15 33,15 33,15 20,2 20,2z M11,2C11,2 18,2 18,2 18,2 31,15 31,15 31,15 24,15 24,15 24,15 11,2 11,2z M2,2C2,2 9,2 9,2 9,2 22,15 22,15 22,15 15,15 15,15 15,15 2,2 2,2z</Geometry>
</Grid.Resources>

<Path Fill="#00b8fc" Data="{StaticResource BarBrushPath}">
    <Path.Clip>
        <RectangleGeometry x:Name="ValueDisplayClip" Rect="0,0,221,13" />
    </Path.Clip>
</Path>

</Grid>

ai_enabled

ai_enabled

2013-08-30 12:10

updater   ~0000713

Yes, it works.
I just want to have CustomControl for displaying bars, with bar presented as rectangle. So I plan to use VisualBrush for healthbar case, and SolidColorBrush for other cases.
Don't bother, I've rewrited this CustomControl to ContentControl :-). It works great - by default I set Rectangle to Content property, in healthbar case I use Path.
Works great! You can look on screenshots here http://atomictorch.com/?p=151

By the way, it would be great if you fix this issue in later releases (1.0.5-1.1.0), and while it's not implemented, add this documentation note:
"Current VisualBrush implementation only works when VisualBrush.Visual refers to a Visual in the logical tree".

Issue History

Date Modified Username Field Change
2013-08-29 08:16 ai_enabled New Issue
2013-08-29 10:57 sfernandez Note Added: 0000708
2013-08-29 10:58 sfernandez Assigned To => sfernandez
2013-08-29 10:58 sfernandez Status new => assigned
2013-08-29 11:02 ai_enabled Note Added: 0000709
2013-08-29 11:17 sfernandez Note Added: 0000710
2013-08-29 12:32 ai_enabled Note Added: 0000711
2013-08-29 13:06 sfernandez Note Added: 0000712
2013-08-30 12:10 ai_enabled Note Added: 0000713
2013-09-23 18:33 sfernandez Priority normal => low
2013-09-23 18:33 sfernandez Category (No Category) => Unity Package
2015-07-23 02:38 jsantos Category Unity Package => Unity3D
2018-11-01 02:14 jsantos View Status public => private
2018-11-23 11:08 sfernandez View Status private => public
2018-11-23 11:08 sfernandez Platform => Any
2025-10-10 13:29 jsantos Category Unity3D => Unity