visualbrush

Set image runtime in VisualBrush with c#

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 01:23:49
actually I set an image took from the resources at designtime into the xaml file like this: <Button Click="btnLogin_Click" Name="btnLogin"> <StackPanel Orientation="Horizontal"> <Rectangle Width="20" Height="20" Name="recLogin"> <Rectangle.Resources> <SolidColorBrush x:Key="BlackBrush" Color="White" /> </Rectangle.Resources> <Rectangle.Fill> <VisualBrush Stretch="Fill" Visual="{StaticResource appbar_user}" x:Name="brushLogin" /> </Rectangle.Fill> </Rectangle> <TextBlock Text=" login" Name="txbLogin" /> </StackPanel> </Button> and works fine. But (is a login button) I wish that when the user do

Get System.Drawing.Bitmap of a WPF Area using VisualBrush

戏子无情 提交于 2019-12-01 23:54:04
The point is, that I need to convert to a System.Drawing.Bitmap (.Net Framework 2.0) to get a single frame of an WPF Grid with its content. I read about VisualBrush and DrawingBrush but I cannot imagine how it should work. I can convert any WPF BitmapSource into my System.Drawing.Bitmap successfully. But how to receive the BitmapSource from my Grid? Thanks To convert a Visual to BitmapSource you can use RenderTargetBitmap , VisualBrush and DrawingVisual : public BitmapSource ConvertToBitmapSource(UIElement element) { var target = new RenderTargetBitmap((int)(element.RenderSize.Width), (int)

Using VisualBrush as OpacityMask

穿精又带淫゛_ 提交于 2019-12-01 09:34:21
问题 I want to set OpacityMask to a control, but I need to build that mask dynamically. Here is how it should look: The width and height of the whole (red) rectangle is dynamic, based on width and height of parent control. But I need to place two small rectangles (static width and height) in top left and top right corner, as shown on image. So how can I make this happen? I tried this code, but it doesn't work: (nothing is displayed at all) <Border BorderBrush="#80FFFFFF" BorderThickness="1"

Snapshots of Control in time using VisualBrush stored in one Fixed(Flow)Document

六眼飞鱼酱① 提交于 2019-12-01 06:13:40
I need to take snapshots of Control in time and store them in one FixedDocument. Problem is that VisualBrush is somehow "lazy" and do not evaluate itself by adding it to document. When I finaly create the document, all pages contains the same (last) state of Control. While VisualBrush cannot be Freezed, is there any other chance to do it? I would like to have more snapshots on one page so generate document page by page isn't solution for me. Aswel as converting VisualBrush to Bitmap (I want to keep it in vectors). In short - I need to somehow Freeze() VisualBrush for(;;) { FixedPage page = new

WPF Binding a visual brush's visual to a different window

拟墨画扇 提交于 2019-11-30 21:44:15
I need a rectangle in my settings window to display a scaled down version of of the main window. This is the non-working code that I have right now. Is it possible to do what I want to do? <Rectangle.Fill> <VisualBrush Stretch="Uniform" Visual="{Binding ElementName=local:MainWindow}" /> </Rectangle.Fill> Yes, but not in pure XAML and not using ElementName. Instead, you'll need to pass a reference to the main window into your settings window. You can then bind the VisualBrush.Visual to that reference. As a simplified example, when creating your settings window, you could set its DataContext to

WPF Binding a visual brush's visual to a different window

那年仲夏 提交于 2019-11-30 05:22:13
问题 I need a rectangle in my settings window to display a scaled down version of of the main window. This is the non-working code that I have right now. Is it possible to do what I want to do? <Rectangle.Fill> <VisualBrush Stretch="Uniform" Visual="{Binding ElementName=local:MainWindow}" /> </Rectangle.Fill> 回答1: Yes, but not in pure XAML and not using ElementName. Instead, you'll need to pass a reference to the main window into your settings window. You can then bind the VisualBrush.Visual to

RenderTargetBitmap + Resource'd VisualBrush = incomplete image

感情迁移 提交于 2019-11-27 15:07:37
问题 I've found a new twist on the "Visual to RenderTargetBitmap" question! I'm rendering previews of WPF stuff for a designer. That means I need to take a WPF visual and render it to a bitmap without that visual ever being displayed. Got a nice little method to do it like to see it here it goes private static BitmapSource CreateBitmapSource(FrameworkElement visual) { Border b = new Border { Width = visual.Width, Height = visual.Height }; b.BorderBrush = Brushes.Black; b.BorderThickness = new