Search Results

Search found 19 results on 1 pages for 'layouttransform'.

Page 1/1 | 1 

  • WPF ToolTip Style with dynamic LayoutTransform

    - by NoOne
    I have an app that scales it's UI and I want to scale the ToolTips with it. I have tried doing this: <Style TargetType="{x:Type ToolTip}"> <Setter Property="LayoutTransform" Value="{DynamicResource scaleTransf}"/> ... </Style> ...where scaleTransf is a resource that I change via code: Application.Current.Resources["scaleTransf"] = new ScaleTransform(...); Most of the ToolTips do get scaled in size but some of them that are created by C# code don't get scaled. I've checked and it seems that I don't set their Style or LayoutTransform by code, so I don't really understand what is going wrong... Moreover, I have the impression that the above XAML code worked fine a few days ago. :( Is there sth I can do to make it work all the time without setting the LayoutTransform in code-behind? EDIT : The ToolTips that don't change scale are the ones that have become visible before. EDIT2 : Extra code: <ScaleTransform x:Key="scaleTransf" ScaleX="1" ScaleY="1"/> I have also tried this: Application.Current.Resources.Remove("scaleTransf"); Application.Current.Resources.Add("scaleTransf", new ScaleTransform(val, val)); EDIT3 : My attempt to solve this using a DependencyProperty: In MainWindow.xaml.cs : public static readonly DependencyProperty TransformToApplyProperty = DependencyProperty.Register("TransformToApply", typeof(Transform), typeof(MainWindow)); public Transform TransformToApply { get { return (Transform)this.GetValue(TransformToApplyProperty); } } Somewhere in MainWindow, in response to a user input: this.SetValue(TransformToApplyProperty, new ScaleTransform(val, val)); XAML Style: <Style TargetType="{x:Type ToolTip}"> <Setter Property="LayoutTransform" Value="{Binding TransformToApply, ElementName=MainWindow}"/> ... Using this code, not a single one of the ToolTips seem to scale accordingly.

    Read the article

  • scale animation for wpf popup

    - by wpf
    I have a nice little popup, when it shows, I d'like it to growth from 0 to 1x scaley, but I don't get it right, when I click multiple times, it looks like i "catch" the animation at various states during the "growth". <Window.Triggers> <EventTrigger RoutedEvent="FrameworkElement.MouseRightButtonDown" > <EventTrigger.Actions> <BeginStoryboard> <Storyboard> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="SimplePopup" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"> <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/> <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </Window.Triggers> and the popup: <Popup Name="SimplePopup" AllowsTransparency="True" StaysOpen="False"> <Popup.LayoutTransform> <TransformGroup> <ScaleTransform ScaleX="1" ScaleY="1" /> <SkewTransform AngleX="0" AngleY="0" /> <RotateTransform Angle="0" /> <TranslateTransform X="0" Y="0" /> </TransformGroup> </Popup.LayoutTransform> <Border> some Content here </Border> </Popup>

    Read the article

  • Binding ElementName

    - by zvi
    Hello First Sorry for my English. I wanted to ask why ElementName does not work the first case, and work in the second. I give the two sections of code . the firts not work <Button Name="button1" Width="100" > <Button.LayoutTransform> <ScaleTransform x:Name="ttt" ScaleX="3" ScaleY="6"/> </Button.LayoutTransform> <Button.Triggers> <EventTrigger RoutedEvent="Path.Loaded"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard RepeatBehavior="Forever"> <DoubleAnimation Storyboard.Target="{Binding ElementName=ttt}" Storyboard.TargetProperty="ScaleX" From="10" To="5" Duration="0:0:1" /> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </Button.Triggers> Button </Button> But it does work <Button Name="button1" Width="100" > <Button.LayoutTransform> <ScaleTransform x:Name="ttt" ScaleX="3" ScaleY="6"/> </Button.LayoutTransform> <Button.Triggers> <EventTrigger RoutedEvent="Path.Loaded"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard RepeatBehavior="Forever"> <DoubleAnimation Storyboard.Target="{Binding ElementName=button1}" Storyboard.TargetProperty="Width" From="100" To="50" Duration="0:0:1" /> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </Button.Triggers> Button </Button> I know I can use Storyboard.TargetName .

    Read the article

  • WPF - binding ElementName problem...

    - by zvi
    Hello First Sorry for my English. I wanted to ask why ElementName does not work the first case, and work in the second. I give the two sections of code . the firts not work <Button Name="button1" Width="100" > <Button.LayoutTransform> <ScaleTransform x:Name="ttt" ScaleX="3" ScaleY="6"/> </Button.LayoutTransform> <Button.Triggers> <EventTrigger RoutedEvent="Path.Loaded"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard RepeatBehavior="Forever"> <DoubleAnimation Storyboard.Target="{Binding ElementName=ttt}" Storyboard.TargetProperty="ScaleX" From="10" To="5" Duration="0:0:1" /> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </Button.Triggers> Button </Button> But it does work <Button Name="button1" Width="100" > <Button.LayoutTransform> <ScaleTransform x:Name="ttt" ScaleX="3" ScaleY="6"/> </Button.LayoutTransform> <Button.Triggers> <EventTrigger RoutedEvent="Path.Loaded"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard RepeatBehavior="Forever"> <DoubleAnimation Storyboard.Target="{Binding ElementName=button1}" Storyboard.TargetProperty="Width" From="100" To="50" Duration="0:0:1" /> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </Button.Triggers> Button </Button> I know I can use Storyboard.TargetName .

    Read the article

  • Easy Scaling in XAML (WPF)

    - by Robert May
    Ran into a problem that needed solving that was kind of fun.  I’m not a XAML guru, and I’m sure there are better solutions, but I thought I’d share mine. The problem was this:  Our designer had, appropriately, designed the system for a 1920 x 1080 screen resolution.  This is for a full screen, touch screen device (think Kiosk), which has that resolution, but we also wanted to demo the device on a tablet (currently using the AWESOME Samsung tablet given out at Microsoft Build).  When you’d run it on that tablet, things were ugly because it was at a lower resolution than the target device. Enter scaling.  I did some research and found out that I probably just need to monkey with the LayoutTransform of some grid somewhere.  This project is using MVVM and has a navigation container that we built that lives on a single root view.  User controls are then loaded into that view as navigation occurs. In the parent grid of the root view, I added the following XAML: <Grid.LayoutTransform> <ScaleTransform ScaleX="{Binding ScaleWidth}" ScaleY="{Binding ScaleHeight}" /> </Grid.LayoutTransform> And then in the root View Model, I added the following code: /// <summary> /// The required design width /// </summary> private const double RequiredWidth = 1920; /// <summary> /// The required design height /// </summary> private const double RequiredHeight = 1080; /// <summary>Gets the ActualHeight</summary> public double ActualHeight { get { return this.View.ActualHeight; } } /// <summary>Gets the ActualWidth</summary> public double ActualWidth { get { return this.View.ActualWidth; } } /// <summary> /// Gets the scale for the height. /// </summary> public double ScaleHeight { get { return this.ActualHeight / RequiredHeight; } } /// <summary> /// Gets the scale for the width. /// </summary> public double ScaleWidth { get { return this.ActualWidth / RequiredWidth; } } Note that View.ActualWidth and View.ActualHeight are just pointing directly at FrameworkElement.ActualWidth and FrameworkElement.ActualHeight. That’s it.  Just calculate the ratio and bind the scale transform to it. Hopefully you’ll find this useful. Technorati Tags: WPF,XAML

    Read the article

  • WPF Separator position

    - by morsanu
    Hey, I'm using a Separator to draw a vertical line inside a Border. At first this was ok because the line needed to be centered, but now I need to position it at a custom x-position from the left border. Is there a way to do that? <Border x:Name="border" ClipToBounds="True" Background="White" BorderBrush="Black" BorderThickness="2"> <Separator BorderBrush="Black" BorderThickness="2"> <Separator.LayoutTransform> <RotateTransform Angle="90" /> </Separator.LayoutTransform> </Separator> </Border>

    Read the article

  • Text orientation

    - by Psytronic
    Hi Guys I know you can do this to get vertical text in a tab header: <Window x:Class="Abodemploy.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300" <Grid <TabControl Margin="0" Name="tabControl1" FlowDirection="LeftToRight" TabStripPlacement="Left" <TabItem <TabItem.Header <StackPanel Orientation="Horizontal" <TextBlockHomes</TextBlock </StackPanel </TabItem.Header <TabItem.LayoutTransform <TransformGroup <RotateTransform Angle="90" / </TransformGroup </TabItem.LayoutTransform <Grid / </TabItem </TabControl </Grid </Window However the text letters are sideways. What I'd like (if possible) is for the letter orientation to be correct (ie upwards), but the text flow downwards, is this possible, or am I just dreaming the impossible dream? Thanks Psy

    Read the article

  • How to set an Image fit to width of ScrollViewer

    - by Raj
    I've Image placed inside a ScrollViewer. <ScrollViewer x:Name="imageScroller" Grid.Column="2" Margin="5" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible"> <Image x:Name="imageViewer" Cursor="Hand" RenderTransformOrigin="0,0" Margin="0"> <Image.LayoutTransform> <ScaleTransform ScaleX="{Binding Path=Zoom, Converter={StaticResource debugConverter}}" ScaleY="{Binding Path=Zoom, Converter={StaticResource debugConverter}}"/> </Image.LayoutTransform> </Image> </ScrollViewer> How do I zoom image like "fit-to-width" in document viewers to the size and height of ScrollViewer?

    Read the article

  • WPF zoom canvas and maintain scroll position

    - by Alex McBride
    I have a Canvas element, contained within a ScrollViewer, which I'm zooming using ScaleTransform. However, I want to be able to keep the scroll position of the viewer focused on the same part of the canvas after the zoom operation has finished. Currently when I zoom the canvas the scroll position of the viewer stays where it was and the place the user was viewing is lost. I'm still learning WPF, and I've been going backwards and forwards a bit on this, but I can't figure out a nice XAML based way to accomplish what I want. Any help in this matter would be greatly appreciated and would aid me in my learning process. Here is the kind of code I'm using... <Grid> <ScrollViewer Name="TrackScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> <Canvas Width="2560" Height="2560" Name="TrackCanvas"> <Canvas.LayoutTransform> <ScaleTransform ScaleX="{Binding ElementName=ZoomSlider, Path=Value}" ScaleY="{Binding ElementName=ZoomSlider, Path=Value}"/> </Canvas.LayoutTransform> <!-- Some complex geometry describing a motor racing circuit --> </Canvas> </ScrollViewer> <StackPanel Orientation="Horizontal" Margin="8" VerticalAlignment="Top" HorizontalAlignment="Left"> <Slider Name="ZoomSlider" Width="80" Minimum="0.1" Maximum="10" Value="1"/> <TextBlock Margin="4,0,0,0" VerticalAlignment="Center" Text="{Binding ElementName=ZoomSlider, Path=Value, StringFormat=F1}"/> </StackPanel> </Grid>

    Read the article

  • Working with Resources in WPF

    - by Coesy
    I am wanting to use the example from http://blogs.microsoft.co.il/blogs/tomershamam/archive/2008/09/22/lt-howto-gt-replace-listview-columns-with-rows-lt-howto-gt.aspx However I don't want to put this into the App.xaml code as this will apply to ALL gridviews, how do I apply this example to a select few gridviews in the application? The Resources look like this <Style TargetType="{x:Type GridViewHeaderRowPresenter}"> <Setter Property="Height" Value="80" /> <Setter Property="LayoutTransform"> <Setter.Value> <TransformGroup> <RotateTransform Angle="-90" /> <ScaleTransform ScaleY="-1" /> </TransformGroup> </Setter.Value> </Setter> </Style> <Style TargetType="{x:Type GridViewRowPresenter}"> <Setter Property="LayoutTransform"> <Setter.Value> <TransformGroup> <RotateTransform Angle="-90" /> <ScaleTransform ScaleY="-1" /> </TransformGroup> </Setter.Value> </Setter> </Style> <LinearGradientBrush x:Key="GridViewColumnHeaderBackground" EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="#FFFFFFFF" Offset="0"/> <GradientStop Color="#FFFFFFFF" Offset="0.4091"/> <GradientStop Color="#FFF7F8F9" Offset="1"/> </LinearGradientBrush> <LinearGradientBrush x:Key="GridViewColumnHeaderBorderBackground" EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="#FFF2F2F2" Offset="0"/> <GradientStop Color="#FFD5D5D5" Offset="1"/> </LinearGradientBrush> <LinearGradientBrush x:Key="GridViewColumnHeaderHoverBackground" EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="#FFBDEDFF" Offset="0"/> <GradientStop Color="#FFB7E7FB" Offset="1"/> </LinearGradientBrush> <LinearGradientBrush x:Key="GridViewColumnHeaderPressBackground" EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="#FF8DD6F7" Offset="0"/> <GradientStop Color="#FF8AD1F5" Offset="1"/> </LinearGradientBrush> <Style x:Key="GridViewColumnHeaderGripper" TargetType="{x:Type Thumb}"> <Setter Property="Canvas.Right" Value="-9"/> <Setter Property="Width" Value="18"/> <Setter Property="Height" Value="{Binding Path=ActualHeight, RelativeSource={RelativeSource TemplatedParent}}"/> <Setter Property="Padding" Value="0"/> <Setter Property="Background" Value="{StaticResource GridViewColumnHeaderBorderBackground}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Thumb}"> <Border Background="Transparent" Padding="{TemplateBinding Padding}"> <Rectangle Fill="{TemplateBinding Background}" HorizontalAlignment="Center" Width="1"/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="{x:Type GridViewColumnHeader}"> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="Background" Value="{StaticResource GridViewColumnHeaderBackground}"/> <Setter Property="BorderBrush" Value="{StaticResource GridViewColumnHeaderBorderBackground}"/> <Setter Property="BorderThickness" Value="0"/> <Setter Property="Padding" Value="2,0,2,0"/> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type GridViewColumnHeader}"> <Grid SnapsToDevicePixels="true"> <Border x:Name="HeaderBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,1,0,1"> <Grid> <Grid.RowDefinitions> <RowDefinition MaxHeight="7"/> <RowDefinition/> </Grid.RowDefinitions> <Rectangle Fill="#FFE3F7FF" x:Name="UpperHighlight" Visibility="Collapsed"/> <Border Grid.RowSpan="2" Padding="{TemplateBinding Padding}"> <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="0,0,0,1" x:Name="HeaderContent" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True"> <ContentPresenter.LayoutTransform> <TransformGroup> <ScaleTransform ScaleY="-1" /> <RotateTransform Angle="90" /> </TransformGroup> </ContentPresenter.LayoutTransform> </ContentPresenter> </Border> </Grid> </Border> <Border Margin="1,1,0,0" x:Name="HeaderHoverBorder" BorderThickness="1,0,1,1"/> <Border Margin="1,0,0,1" x:Name="HeaderPressBorder" BorderThickness="1,1,1,0"/> <Canvas> <Thumb x:Name="PART_HeaderGripper" Style="{StaticResource GridViewColumnHeaderGripper}"/> </Canvas> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="true"> <Setter Property="Background" TargetName="HeaderBorder" Value="{StaticResource GridViewColumnHeaderHoverBackground}"/> <Setter Property="BorderBrush" TargetName="HeaderHoverBorder" Value="#FF88CBEB"/> <Setter Property="Visibility" TargetName="UpperHighlight" Value="Visible"/> <Setter Property="Background" TargetName="PART_HeaderGripper" Value="Transparent"/> </Trigger> <Trigger Property="IsPressed" Value="true"> <Setter Property="Background" TargetName="HeaderBorder" Value="{StaticResource GridViewColumnHeaderPressBackground}"/> <Setter Property="BorderBrush" TargetName="HeaderHoverBorder" Value="#FF95DAF9"/> <Setter Property="BorderBrush" TargetName="HeaderPressBorder" Value="#FF7A9EB1"/> <Setter Property="Visibility" TargetName="UpperHighlight" Value="Visible"/> <Setter Property="Fill" TargetName="UpperHighlight" Value="#FFBCE4F9"/> <Setter Property="Visibility" TargetName="PART_HeaderGripper" Value="Hidden"/> <Setter Property="Margin" TargetName="HeaderContent" Value="1,1,0,0"/> </Trigger> <Trigger Property="Height" Value="Auto"> <Setter Property="MinHeight" Value="20"/> </Trigger> <Trigger Property="IsEnabled" Value="false"> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="Role" Value="Floating"> <Setter Property="Opacity" Value="0.4082"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type GridViewColumnHeader}"> <Canvas x:Name="PART_FloatingHeaderCanvas"> <Rectangle Fill="#FF000000" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}" Opacity="0.4697"/> </Canvas> </ControlTemplate> </Setter.Value> </Setter> </Trigger> <Trigger Property="Role" Value="Padding"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type GridViewColumnHeader}"> <Border x:Name="HeaderBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,1,0,1"/> <ControlTemplate.Triggers> <Trigger Property="Height" Value="Auto"> <Setter Property="MinHeight" Value="20"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> I have tried creating a usercontrol and sticking that lot in the UserControl.Resources section but it didn't work, I can only get this example to work if i put them into the Application.Resources section which i obviously don't want. Help!! :-)

    Read the article

  • Wpf: Storyboard.TargetName works, but Setter TargetName doesn't.

    - by MainMa
    Hi, Let's say we have a XAML code like this: <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBoxItem}"> <Border HorizontalAlignment="Center" VerticalAlignment="Center"> <Border.LayoutTransform> <!--We are rotating randomly each image. Selected one will be rotated to 45°.--> <RotateTransform Angle="{Binding RandomAngle}" x:Name="globalRotation"/> </Border.LayoutTransform> <Grid> <Image Source="{Binding ImageLocation}" Stretch="None" /> <TextBlock x:Name="title" Text="{Binding Title}" /> </Grid> </Border> <ControlTemplate.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter TargetName="title" Property="Visibility" Value="Visible"/> <!--The next line will not compile.--> <Setter TargetName="globalRotation" Property="Angle" Value="45"/> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> <!--This compiles well.--> <DoubleAnimation Storyboard.TargetName="globalRotation" Storyboard.TargetProperty="Angle" To="45" Duration="00:00:03"/> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> This code is intended to display a set of images in a listbox. Each image has a random rotation, but when selected, rotates to 45 degrees. Rotating selected image through a storyboard works well. I just specify Storyboard.TargetName and it rotates the image when selected (Trigger.ExitActions is omitted to make the code shorter). Now, if I want, instead of using a storyboard, assign 45 degrees value directly, I can't do that, because <Setter TargetName="globalRotation" Property="Angle" Value="45"/>: it compiles with "Cannot find the Trigger target 'globalRotation'. (The target must appear before any Setters, Triggers, or Conditions that use it.)" error. What happens? I suppose that Storyboard.TargetName is evaluated during runtime, so let me compile it. Is it right? How to make it work with just a setter, without using a storyboard?

    Read the article

  • WPF Zoom with ScaleTransform overlap all Window

    - by Andrew
    Hi, i want to create Pan & Zoom control Similar thread, so i transform control with ScaleTransform and it overlaps all window, i have ot do it with RenderTransform, becouse with LayoutTransform Pan implemented in example doesn't work. Are there any properties or templates with which i can implement behavior like this: if content of container undergo transformation (or just move), if content doesn't fit, container shows only fitted part, something like this: <Container Height="100" Width="100" DisplayOption="CutAllThatNotFit"> <Content/> </Container>

    Read the article

  • How to specify the image scaling algorithm used by a WPF Image?

    - by mackenir
    Is there a way to specify how an image is scaled up in an Image element with LayoutTransform set to a ScaleTransform with integer values for ScaleX and ScaleY? I want to display the scaled image crisply (ie using 'nearest neighbour' scaling), with no blurring. (Imagine how you would want a bitmap editing program to behave when zooming in). I noticed the protected property VisualBitmapScalingMode on Image, so created a subclass of Image that sets this property to BitmapScalingMode.NearestNeighbor. However, this had no effect.

    Read the article

  • Displaying xaml resources dynamically?

    - by Robert
    I used Mike Swanson's illustrator to xaml converter to convert some of my images to xaml. The convert creates a viewbox that contains the image. These viewboxes I made resource files in my program. The code below shows what I'm trying to do: I have a viewmodel that has an enum variable called PrimaryWinding of type Windings. The values PrimD and PrimY of the enum select the respective PrimD and PrimY xaml files in the resources. <UserControl.Resources> <DataTemplate x:Key="PrimTrafo" DataType="{x:Type l:Windings}"> <Frame Source="{Binding}" x:Name="PART_Image" NavigationUIVisibility="Hidden"> <Frame.LayoutTransform> <ScaleTransform ScaleX="0.5" ScaleY="0.5"/> </Frame.LayoutTransform> </Frame> <DataTemplate.Triggers> <DataTrigger Binding="{Binding}" Value="PrimD"> <Setter TargetName="PART_Image" Property="Source" Value="Resources\PrimD.xaml" /> </DataTrigger> <DataTrigger Binding="{Binding}" Value="PrimY"> <Setter TargetName="PART_Image" Property="Source" Value="Resources\PrimY.xaml" /> </DataTrigger> </DataTemplate.Triggers> </DataTemplate> </UserControl.Resources> <!--The contentcontrol that holds the datatemplate defined above--> <Grid > <Grid.ColumnDefinitions> <ColumnDefinition Width="2*"></ColumnDefinition> <ColumnDefinition Width="2*"></ColumnDefinition> <ColumnDefinition Width="1*"></ColumnDefinition> </Grid.ColumnDefinitions> <ContentControl Grid.Column="0" Content="{Binding PrimaryWinding}" ContentTemplate="{StaticResource PrimTrafo}"/> </Grid> This code works. Only I can't resize the drawings to the size of the grid cell. I added the ScaleTransform class to resize the image. Is a Frame the wrong class to hold the drawings? Should I use the ScaleTransform class to resize the drawing to the size of the cell? And how can I do that dynamically?

    Read the article

  • Custom ProgressBarBrushConverter Not Filling In ProgressBar

    - by Wonko the Sane
    Hello All, I am attempting to create a custom ProgressBarBrushConverter, based on information from here and here. However, when it runs, the progress is not being shown. If I use the code found in the links, it appears to work correctly. Here is the converter in question: public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { ProgressBar progressBar = null; foreach (object value in values) { if (value is ProgressBar) { progressBar = value as ProgressBar; break; } } if (progressBar == null) return DependencyProperty.UnsetValue; FrameworkElement indicator = progressBar.Template.FindName("PART_Indicator", progressBar) as FrameworkElement; DrawingBrush drawingBrush = new DrawingBrush(); drawingBrush.Viewport = drawingBrush.Viewbox = new Rect(0.0, 0.0, indicator.ActualWidth, indicator.ActualHeight); drawingBrush.ViewportUnits = BrushMappingMode.Absolute; drawingBrush.TileMode = TileMode.None; drawingBrush.Stretch = Stretch.None; DrawingGroup group = new DrawingGroup(); DrawingContext context = group.Open(); context.DrawRectangle(progressBar.Foreground, null, new Rect(0.0, 0.0, indicator.ActualWidth, indicator.ActualHeight)); context.Close(); drawingBrush.Drawing = group; return drawingBrush; } Here is the ControlTemplate (the MultiBinding is to make sure that the converter is called whenever the Value or IsIndeterminate properties are changed): <ControlTemplate x:Key="customProgressBarTemplate" TargetType="{x:Type ProgressBar}"> <Grid> <Path x:Name="PART_Track" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="Fill" StrokeLineJoin="Round" Stroke="#DDCBCBCB" StrokeThickness="4" Data="M 20,100 L 80,10 C 100,120 160,140 190,180 S 160,220 130,180 T 120,150 20,100 Z "> <Path.Fill> <MultiBinding> <MultiBinding.Converter> <local:ProgressBarBrushConverter /> </MultiBinding.Converter> <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type ProgressBar}}" /> <Binding Path="IsIndeterminate" RelativeSource="{RelativeSource TemplatedParent}"/> <Binding Path="Value" RelativeSource="{RelativeSource TemplatedParent}"/> </MultiBinding> </Path.Fill> <!--<Path.LayoutTransform> <RotateTransform Angle="180" CenterX="190" CenterY="110" /> </Path.LayoutTransform>--> </Path> <Rectangle x:Name="PART_Indicator" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="1" /> </Grid> </ControlTemplate> Finally, the Window code (fairly straightforward - it just animates progress from 0 to 100 and back again): <ProgressBar x:Name="progress" Template="{StaticResource customProgressBarTemplate}" Foreground="Red"> <ProgressBar.Triggers> <EventTrigger RoutedEvent="ProgressBar.Loaded"> <BeginStoryboard x:Name="storyAnimate"> <Storyboard> <DoubleAnimationUsingKeyFrames Duration="0:0:12" AutoReverse="True" FillBehavior="Stop" RepeatBehavior="Forever" Storyboard.TargetName="progress" Storyboard.TargetProperty="(ProgressBar.Value)"> <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0" /> <LinearDoubleKeyFrame Value="100" KeyTime="0:0:5" /> <LinearDoubleKeyFrame Value="100" KeyTime="0:0:6" /> <LinearDoubleKeyFrame Value="0" KeyTime="0:0:11" /> <LinearDoubleKeyFrame Value="0" KeyTime="0:0:12" /> </DoubleAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </EventTrigger> </ProgressBar.Triggers> </ProgressBar> I am thinking that the problem is in the DrawRectangle call in the Convert method, but setting a TracePoint on it shows what appear to be valid values for the Rect. What am I missing here? Thanks, wTs

    Read the article

  • How do I get the co-ordinates of a mouse click on a transformed WPF control?

    - by BlackWasp
    I'm playing with a simple WPF application. One part of it includes a grid containing several controls. The grid is rotated using a LayoutTransform and a RotateTransform. I need to get the co-ordinates of a mouse-click relative to the top-left of the grid, taking the rotation into account. To be clear, let's say I have a single drawing surface within the grid and no transform had been applied. I then click at location X = 20, Y = 10 and put a dot on the drawing surface at that point. If the grid is now rotated by 30 degrees and I click on the dot (which is also moved by the rotation), the click position should still be X = 20, Y = 10.

    Read the article

  • ScaleTransform transforms non-linearly

    - by Chris
    I am using scale transform to allow a user to resize a control. What happens though is that when you start to move the mouse the control jumps to a new size, and then scales oddly. The further you move your mouse from the starting location the larger the increase in size becomes. I expect its the way I calculate the scale to be applied. Here is the code: private void ResizeGrip_MouseDown(object sender, MouseButtonEventArgs e) { ResizeHandle.CaptureMouse(); //Get the initial coordinate cursor location on the window initBtmX = e.GetPosition(this).X; bottomResize = true; } private void ResizeGrip_MouseUp(object sender, MouseButtonEventArgs e) { bottomResize = false; ResizeHandle.ReleaseMouseCapture(); } private void ResizeGrip_MouseMove(object sender, MouseEventArgs e) { if( bottomResize == true) { //Get the new Y coordinate cursor location double newBtmX = e.GetPosition(this).X; //Get the smallest change between the initial and new cursor location double diffX = initBtmX - newBtmX; // Let our rectangle capture the mouse ResizeHandle.CaptureMouse(); double newWidth = e.GetPosition(this).X - diffX; double scaler = newWidth / ResizeContainer.ActualWidth; Console.WriteLine("newWidth: {0}, scalar: {1}", newWidth, scaler); if (scaler < 0.75 || scaler > 3) return; ScaleTransform scale = new ScaleTransform(scaler, scaler); ResizeContainer.LayoutTransform = scale; } }

    Read the article

  • WPF Datagrid zoom issue

    - by David Osborn
    I'm working with the WPF DataGrid from the WPFToolkit and I'm having issues with trying to zoom the entire datagrid. My initial thought was that it was going to be really easy and I would just apply a scale transform to the grid and animate the ScaleX, ScaleY properties when the used clicked a button. This did not work however because the scrollbar was zoomed in making it larger. I need fixed headers and fixed columns on the datagrid so I can't simple use a scrollviewer outside of the datagrid to handle the scrolling. The second thing I tried was to just scale the font size in the grid, but this failed because on shrinking the font size the columns stay at the original width and do not shrink. Finally I thought I had it working by using the below code which goes into the view tree for the datagrid and adds a scale transform to the Scroll Content Presenter. (Also not shown in this code, I apply a transform to the visual tree item for the headers in the same manner so that it scales as well). I thought this was working great until I tested out the horizontal scrolling after zooming. (Vertical scrolling works perfectly.) Before zooming at all the horizontal scrolling is fine, but after zooming, when I scroll horzonitally the display freaks out. It is hard to tell exactly what it is doing, but it sort of looks like the content that is scrolling off the left of the screen is "folding over" and coming back in on the left. Maybe it is just all smashing up on the left side. Does anyone have any ideas how I can get this working, hopefully without throwing out my whole datagrid that is already working quite well otherwise. ScrollContentPresenter sp = (ScrollContentPresenter) VisualTreeHelper.GetChild( VisualTreeHelper.GetChild( VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(dgMatrix, 0), 0), 0),2); ScaleTransform st = new ScaleTransform(1, 1); sp.LayoutTransform = st; DoubleAnimation a = new DoubleAnimation(); a.By = 1.5; a.AutoReverse = false; a.Duration = new Duration(TimeSpan.Parse("0:0:0.25")); st.BeginAnimation(ScaleTransform.ScaleXProperty, a); st.BeginAnimation(ScaleTransform.ScaleYProperty, a);

    Read the article

  • WPF: adding Style to a slider

    - by user279244
    Hi I am using a Slider and putting a style element over it as follows... But however, I am not able to figure out why the style is not getting reflected. The RepeatButtons are not still visible. Thanks in advance <ResourceDictionary> <LinearGradientBrush x:Key="Stroke_Gradient" EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF6E6E6E" Offset="0"/> <GradientStop Color="#FFFFFFFF" Offset="0.496"/> <GradientStop Color="#FF6E6E6E" Offset="1"/> </LinearGradientBrush> <Style x:Key="ScrollBar_RepeatButtonStyle1" d:IsControlPart="True" TargetType="{x:Type RepeatButton}"> <Setter Property="Background" Value="#FF6E6E6E"/> <Setter Property="BorderBrush" Value="#FFFFFFFF"/> <Setter Property="IsTabStop" Value="false"/> <Setter Property="Focusable" Value="false"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type RepeatButton}"> <Grid> <Rectangle Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> <ImageBrush x:Key="zoomBkgrnd" TileMode="None" ImageSource="zoombg.png" Stretch="Uniform"/> <Style x:Key="{x:Type Slider}" TargetType="{x:Type Slider}"> <Setter Property="Background" Value="{StaticResource zoomBkgrnd}"/> <Setter Property="BorderBrush" Value="{StaticResource zoomBkgrnd}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Slider}"> <Grid x:Name="GridRoot"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <!-- TickBar shows the ticks for Slider --> <TickBar Visibility="Collapsed" x:Name="TopTick" Height="4" SnapsToDevicePixels="True" Placement="Top" Fill="{StaticResource zoomBkgrnd}"/> <Border Grid.Row="1" Margin="0" x:Name="Border" Height="4" Background="{StaticResource zoomBkgrnd}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"/> <!-- The Track lays out the repeat buttons and thumb --> <Track Grid.Row="1" x:Name="PART_Track"> <Track.Thumb> <Thumb Width="10" Height="20" /> </Track.Thumb> <Track.IncreaseRepeatButton> <RepeatButton Style="{DynamicResource ScrollBar_RepeatButtonStyle1}" Command="Slider.IncreaseLarge"/> </Track.IncreaseRepeatButton> <Track.DecreaseRepeatButton> <RepeatButton Style="{DynamicResource ScrollBar_RepeatButtonStyle1}" Command="Slider.DecreaseLarge"/> </Track.DecreaseRepeatButton> </Track> <TickBar Visibility="Collapsed" Grid.Row="2" x:Name="BottomTick" Height="4" SnapsToDevicePixels="True" Placement="Bottom" Fill="{TemplateBinding Foreground}"/> </Grid> <ControlTemplate.Triggers> <Trigger Property="TickPlacement" Value="TopLeft"> <Setter Property="Visibility" Value="Visible" TargetName="TopTick"/> </Trigger> <Trigger Property="TickPlacement" Value="BottomRight"> <Setter Property="Visibility" Value="Visible" TargetName="BottomTick"/> </Trigger> <Trigger Property="TickPlacement" Value="Both"> <Setter Property="Visibility" Value="Visible" TargetName="TopTick"/> <Setter Property="Visibility" Value="Visible" TargetName="BottomTick"/> </Trigger> <Trigger Property="IsEnabled" Value="false"> <Setter Property="Background" Value="{StaticResource zoomBkgrnd}" TargetName="Border"/> <Setter Property="BorderBrush" Value="{StaticResource zoomBkgrnd}" TargetName="Border"/> </Trigger> <!-- Use a rotation to create a Vertical Slider form the default Horizontal --> <Trigger Property="Orientation" Value="Vertical"> <Setter Property="LayoutTransform" TargetName="GridRoot"> <Setter.Value> <RotateTransform Angle="-90"/> </Setter.Value> </Setter> <!-- Track rotates itself based on orientation so need to force it back --> <Setter TargetName="PART_Track" Property="Orientation" Value="Horizontal"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary>

    Read the article

1