Search Results

Search found 59 results on 3 pages for 'scaletransform'.

Page 2/3 | < Previous Page | 1 2 3  | Next Page >

  • WPF performance on scaling a large scene

    - by Mark
    I have a full screen app that I want to be able to zoom in on certain areas. I have the code working fine, but I notice that when I get closer in, the zoom in animation (which animates the ScaleTransform.ScaleX and ScaleTransform.ScaleY properties on a Parent canvas) starts to jerk down a little and the frame rate suffers. Im not using any BitmapEffects or anything, and ideally I would like my scene to get more complicated than it currently already is. The scene is quite large, 1980x1024, this is a requirement and cannot be changed. The current layout is like this: <Canvas x:name="LayoutRoot"> <Canvas x:Name="ContainerCanvas"> <local:MyControl x:Name="c1" /> <!-- numerous or ther controls and elements that compose the scene --> </Canvas> </Canvas> The code that zooms in just animates the RenderTransform of the ContainerCanvas, which in tern, scales its children which gives the desired effect. However, Im wondering if I need to swap out the ContainerCanvas for a ViewBox or something like that? Ive never really worked with ViewBox/Viewport controls before in WPF can they even help me out here? Smooth zooming is a huge requirement of the client and I must get this resolved. All ideas are welcome Thanks a lot Mark

    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

  • CATransaction: Layer Changes But Does Not Animate

    - by macinjosh
    I'm trying to animate part of UI in an iPad app when the user taps a button. I have this code in my action method. It works in the sense that the UI changes how I expect but it does not animate the changes. It simply immediately changes. I must be missing something: - (IBAction)someAction:(id)sender { UIViewController *aViewController = <# Get an existing UIViewController #>; UIView *viewToAnimate = aViewController.view; CALayer *layerToAnimate = viewToAnimate.layer; [CATransaction begin]; [CATransaction setAnimationDuration:1.0f]; CATransform3D rotateTransform = CATransform3DMakeRotation(0.3, 0, 0, 1); CATransform3D scaleTransform = CATransform3DMakeScale(0.10, 0.10, 0.10); CATransform3D positionTransform = CATransform3DMakeTranslation(24, 423, 0); CATransform3D combinedTransform = CATransform3DConcat(rotateTransform, scaleTransform); combinedTransform = CATransform3DConcat(combinedTransform, positionTransform); layerToAnimate.transform = combinedTransform; [CATransaction commit]; // rest of method... } I've tried simplifying the animation to just change the opacity (for example) and it still will not animate. The opacity just changes instantly. That leads me to believe something is not setup properly. Any clues would be helpful!

    Read the article

  • Migrate style from TabItem to TabHeader

    - by OffApps Cory
    Good day! I have a TabControl with TabItems that have been customized via a control template. This control template specifies a trigger whereby on mouseover, the content of tab header grows slightly. <ControlTemplate> <Storyboard x:Key="TabHeaderGrow"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="TabName" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"> <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.1"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="TabName" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"> <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.1"/> </DoubleAnimationUsingKeyFrames> </Storyboard> <ControlTemplate.Triggers> <EventTrigger RoutedEvent="Mouse.MouseEnter"> <BeginStoryboard Storyboard="{StaticResource TabHeaderGrow}"/> </EventTrigger> When I mouseover any of the tabs they work as expected, however the trigger also fires when I mouseover any of the elements in the tab body. I know that I need to migrate the control styling to a tabHeader controlTemplate, but I am unsure how to do that. I can't seem to do template binding for the content of the tabheader. Any help would be appreciated.

    Read the article

  • Plane projection and scale causing bluring in silverlight

    - by Andy
    Ok, So I've tried to make an application which relies on images being scaled by an individual factor. These images are then able to be turned over, but the use of an animation working on the ProjectionPlane rotation. The problem comes around when an image is both scaled and rotated. For some reason it starts bluring, where a non scaled image doesn't blur. Also, if you look at the example image below (top is scaled and rotated, bottom is rotated) the projection of the top one doesn't even seem right. Its too horizontal. This this the code for the test app: <UserControl x:Class="SilverlightApplication1.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="400" Height="300"> <Canvas x:Name="LayoutRoot" Background="White"> <Border Canvas.Top="25" Canvas.Left="50"> <Border.RenderTransform> <TransformGroup> <ScaleTransform ScaleX="3" ScaleY="3" /> </TransformGroup> </Border.RenderTransform> <Border.Projection> <PlaneProjection RotationY="45"/> </Border.Projection> <Image Source="bw-test-pattern.jpg" Width="50" Height="40"/> </Border> <Border Canvas.Top="150" Canvas.Left="50"> <Border.RenderTransform> <TransformGroup> <ScaleTransform ScaleX="1" ScaleY="1" /> </TransformGroup> </Border.RenderTransform> <Border.Projection> <PlaneProjection RotationY="45"/> </Border.Projection> <Image Source="bw-test-pattern.jpg" Width="150" Height="120"/> </Border> </Canvas> </UserControl> So if anyone could possible shed any light on why this may be happening, I'd very much appreciate it. Suggestions also welcome! :)

    Read the article

  • Tiling rectangles seamlessly in WPF

    - by Joe White
    I want to seamlessly tile a bunch of different-colored Rectangles in WPF. That is, I want to put a bunch of rectangles edge-to-edge, and not have gaps between them. If everything is aligned to pixels, this works fine. But I also want to support arbitrary zoom, and ideally, I don't want to use SnapsToDevicePixels (because it would compromise quality when the image is zoomed way out). But that means my Rectangles sometimes render with gaps. For example: <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="Black"> <Canvas SnapsToDevicePixels="False"> <Canvas.RenderTransform> <ScaleTransform ScaleX="0.5" ScaleY="0.5"/> </Canvas.RenderTransform> <Rectangle Canvas.Left="25" Width="100" Height="100" Fill="#CFC"/> <Rectangle Canvas.Left="125" Width="100" Height="100" Fill="#CCF"/> </Canvas> </Page> If the ScaleTransform's ScaleX is 1, then the Rectangles fit together seamlessly. When it's 0.5, there's a dark gray streak between them. I understand why -- the combined semi-transparent edge pixels don't combine to be 100% opaque. But I would like a way to fix it. I could always just make the Rectangles overlap, but I won't always know in advance what patterns they'll be in (this is for a game that will eventually support a map editor). Besides, this would cause artifacts around the overlap area when things were zoomed way in (unless I did bevel-cut angles on the underlapping portion, which is an awful lot of work, and still causes problems at corners). Is there some way I can combine these Rectangles into a single combined "shape" that does render without internal gaps? I've played around with GeometryDrawing, which does exactly that, but then I don't see a way to paint each RectangleGeometry with a different-colored brush. Are there any other ways to get shapes to tile seamlessly under an arbitrary transform, without resorting to SnapsToDevicePixels?

    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

  • WPF Infinite loop in references found while processing the Template

    - by Ryan
    I am pretty new to WPF and am getting this error after my mouse is over my custom listbox item. Error: Infinite loop in references found while processing the Template for an element named '' of type 'System.Windows.Controls.TextBox'. <Window.Resources> <ControlTemplate x:Key="MouseOverFocusTemplate" > <Grid> <Grid.RowDefinitions> <RowDefinition Height="55*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <TextBox Width="290" TextAlignment="Left" VerticalContentAlignment="Center" BorderThickness="0" BorderBrush="Transparent" Foreground="#FF6FB8FD" FontSize="24" TextWrapping="Wrap" Text="{Binding .}" Grid.Column="1" Grid.Row="1" MinHeight="55" Cursor="Hand" IsReadOnly="True" FontFamily="Arial" > <TextBox.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF013B73" Offset="0.501"/> <GradientStop Color="#FF091F34"/> <GradientStop Color="#FF014A8F" Offset="0.5"/> <GradientStop Color="#FF003363" Offset="1"/> </LinearGradientBrush> </TextBox.Background> </TextBox> </Grid> </ControlTemplate> <Style x:Key="MouseOverFocusStyle" TargetType="{x:Type TextBox}"> <Setter Property="Template" Value="{StaticResource MouseOverFocusTemplate}"/> </Style> <ControlTemplate x:Key="LostFocusTemplate" > <Grid> <Grid.RowDefinitions> <RowDefinition Height="55*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <TextBox Width="290" TextAlignment="Left" VerticalContentAlignment="Center" BorderThickness="0" BorderBrush="Transparent" Foreground="#FF6FB8FD" FontSize="24" TextWrapping="Wrap" Text="{Binding .}" Grid.Column="1" Grid.Row="1" MinHeight="55" Cursor="Hand" IsReadOnly="True" FontFamily="Arial" > <TextBox.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <LinearGradientBrush.RelativeTransform> <TransformGroup> <ScaleTransform CenterX="0.5" CenterY="0.5"/> <SkewTransform CenterX="0.5" CenterY="0.5"/> <RotateTransform CenterX="0.5" CenterY="0.5"/> <TranslateTransform/> </TransformGroup> </LinearGradientBrush.RelativeTransform> <GradientStop Color="#FF091F34" Offset="1"/> <GradientStop Color="#FF002F5C" Offset="0.4"/> </LinearGradientBrush> </TextBox.Background> </TextBox> </Grid> </ControlTemplate> <Style x:Key="LostFocusStyle" TargetType="{x:Type TextBox}"> <Setter Property="Template" Value="{StaticResource LostFocusTemplate}"/> </Style> <ControlTemplate x:Key="GotFocusTemplate" > <Grid> <Grid.RowDefinitions> <RowDefinition Height="55*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <TextBox Width="290" TextAlignment="Left" VerticalContentAlignment="Center" BorderThickness="0" BorderBrush="Transparent" Foreground="#FFE38E27" FontSize="24" TextWrapping="Wrap" Text="{Binding .}" Grid.Column="1" Grid.Row="1" MinHeight="55" Cursor="Hand" IsReadOnly="True" FontFamily="Arial" > <TextBox.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="Black" Offset="0.501"/> <GradientStop Color="#FF091F34"/> <GradientStop Color="#FF002F5C" Offset="0.5"/> </LinearGradientBrush> </TextBox.Background> </TextBox> </Grid> </ControlTemplate> <Style x:Key="GotFocusStyle" TargetType="{x:Type TextBox}"> <Setter Property="Template" Value="{StaticResource GotFocusTemplate}"/> </Style> <Style TargetType="ListBoxItem"> <EventSetter Event="GotFocus" Handler="ListItem_GotFocus"></EventSetter> <EventSetter Event="LostFocus" Handler="ListItem_LostFocus"></EventSetter> <EventSetter Event="Mouse.MouseMove" Handler="ListItem_MouseOver"></EventSetter> </Style> <DataTemplate DataType="{x:Type TextBlock}"> </DataTemplate> <DataTemplate x:Key="CustomListData" DataType="{x:Type ListBoxItem}"> <Border BorderBrush="Black" BorderThickness="1" Margin="-2,0,0,-1"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="55*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RenderTransform> <TransformGroup> <ScaleTransform ScaleX="1" ScaleY="1"/> <SkewTransform AngleX="0" AngleY="0"/> <RotateTransform Angle="0"/> <TranslateTransform X="0" Y="0"/> </TransformGroup> </Grid.RenderTransform> <!--<ScrollViewer x:Name="PART_ContentHost" />--> <TextBox Width="290" TextAlignment="Left" VerticalContentAlignment="Center" BorderThickness="0" BorderBrush="Transparent" Foreground="#FF6FB8FD" FontSize="24" FocusVisualStyle="{StaticResource GotFocusStyle}" TextWrapping="Wrap" Text="{Binding .}" Grid.Column="1" Grid.Row="1" MinHeight="55" Cursor="Hand" IsReadOnly="True" FontFamily="Arial" > <TextBox.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <LinearGradientBrush.RelativeTransform> <TransformGroup> <ScaleTransform CenterX="0.5" CenterY="0.5"/> <SkewTransform CenterX="0.5" CenterY="0.5"/> <RotateTransform CenterX="0.5" CenterY="0.5"/> <TranslateTransform/> </TransformGroup> </LinearGradientBrush.RelativeTransform> <GradientStop Color="#FF091F34" Offset="1"/> <GradientStop Color="#FF002F5C" Offset="0.4"/> </LinearGradientBrush> </TextBox.Background> </TextBox> </Grid> </Border> </DataTemplate> <Style TargetType="{x:Type ListBox}"> <Setter Property="ItemTemplate" Value="{StaticResource CustomListData }" /> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /> </Style> </Window.Resources> <Window.DataContext> <ObjectDataProvider ObjectType="{x:Type local:ImageLoader}" MethodName="LoadImages" /> </Window.DataContext> <ListBox ItemsSource="{Binding}" Width="320" Background="#FF021422" BorderBrush="#FF1C4B79"> <ListBox.Resources> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}">Transparent</SolidColorBrush> </ListBox.Resources> </ListBox> The code behind for the mouse over event is as follows private void ListItem_MouseOver(object sender, RoutedEventArgs e) { e.Handled = true; FrameworkElement element = e.OriginalSource as FrameworkElement; if (element != null) { while (VisualTreeHelper.GetParent(element) != null) { element = VisualTreeHelper.GetParent(element) as FrameworkElement; TextBox item = element as TextBox; if (item != null) { item.Style = (Style)item.FindResource("MouseOverFocusStyle"); return; } } } } What am I missing? Is there an easier way to do this ? Thanks in advance Ryan

    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 Custom ListBox as Buttons Click not firing

    - by Ryan
    I am attempting to have a ListBox of TextBoxes with click events. I have read that one way to achieve this was to have a list of Buttons and call ButtonBase.Click="" on the ListBox. This was not working. Any advice as to how I would hook up a click event to the listbox items? Thanks <Window.Resources> <ControlTemplate x:Key="MouseOverFocusTemplate" > <Grid> <Grid.RowDefinitions> <RowDefinition Height="55*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <TextBox Width="290" TextAlignment="Left" VerticalContentAlignment="Center" BorderThickness="0" BorderBrush="Transparent" Foreground="#FF6FB8FD" FontSize="24" TextWrapping="Wrap" Text="{Binding .}" Grid.Column="1" Grid.Row="1" MinHeight="55" Cursor="Hand" IsReadOnly="True" FontFamily="Arial" > <TextBox.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF013B73" Offset="0.501"/> <GradientStop Color="#FF091F34"/> <GradientStop Color="#FF014A8F" Offset="0.5"/> <GradientStop Color="#FF003363" Offset="1"/> </LinearGradientBrush> </TextBox.Background> </TextBox> </Grid> </ControlTemplate> <Style x:Key="MouseOverFocusStyle" TargetType="{x:Type TextBox}"> <Setter Property="Template" Value="{StaticResource MouseOverFocusTemplate}"/> </Style> <ControlTemplate x:Key="LostFocusTemplate" > <Grid> <Grid.RowDefinitions> <RowDefinition Height="55*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <TextBox Width="290" TextAlignment="Left" VerticalContentAlignment="Center" BorderThickness="0" BorderBrush="Transparent" Foreground="#FF6FB8FD" FontSize="24" TextWrapping="Wrap" Text="{Binding .}" Grid.Column="1" Grid.Row="1" MinHeight="55" Cursor="Hand" IsReadOnly="True" FontFamily="Arial" > <TextBox.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <LinearGradientBrush.RelativeTransform> <TransformGroup> <ScaleTransform CenterX="0.5" CenterY="0.5"/> <SkewTransform CenterX="0.5" CenterY="0.5"/> <RotateTransform CenterX="0.5" CenterY="0.5"/> <TranslateTransform/> </TransformGroup> </LinearGradientBrush.RelativeTransform> <GradientStop Color="#FF091F34" Offset="1"/> <GradientStop Color="#FF002F5C" Offset="0.4"/> </LinearGradientBrush> </TextBox.Background> </TextBox> </Grid> </ControlTemplate> <Style x:Key="LostFocusStyle" TargetType="{x:Type TextBox}"> <Setter Property="Template" Value="{StaticResource LostFocusTemplate}"/> </Style> <ControlTemplate x:Key="GotFocusTemplate" > <Grid> <Grid.RowDefinitions> <RowDefinition Height="55*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <TextBox Width="290" TextAlignment="Left" VerticalContentAlignment="Center" BorderThickness="0" BorderBrush="Transparent" Foreground="#FFE38E27" FontSize="24" TextWrapping="Wrap" Text="{Binding .}" Grid.Column="1" Grid.Row="1" MinHeight="55" Cursor="Hand" IsReadOnly="True" FontFamily="Arial" > <TextBox.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="Black" Offset="0.501"/> <GradientStop Color="#FF091F34"/> <GradientStop Color="#FF002F5C" Offset="0.5"/> </LinearGradientBrush> </TextBox.Background> </TextBox> </Grid> </ControlTemplate> <Style x:Key="GotFocusStyle" TargetType="{x:Type TextBox}"> <Setter Property="Template" Value="{StaticResource GotFocusTemplate}"/> </Style> <Style TargetType="{x:Type Button}" x:Key="listButton"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Border BorderBrush="Black" BorderThickness="1" Margin="-2,0,0,-1"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="55*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RenderTransform> <TransformGroup> <ScaleTransform ScaleX="1" ScaleY="1"/> <SkewTransform AngleX="0" AngleY="0"/> <RotateTransform Angle="0"/> <TranslateTransform X="0" Y="0"/> </TransformGroup> </Grid.RenderTransform> <!--<ScrollViewer x:Name="PART_ContentHost" />--> <TextBox Width="290" TextAlignment="Left" VerticalContentAlignment="Center" BorderThickness="0" BorderBrush="Transparent" Foreground="#FF6FB8FD" FontSize="24" Style="{StaticResource LostFocusStyle}" TextWrapping="Wrap" Text="{Binding .}" Grid.Column="1" Grid.Row="1" MinHeight="55" Cursor="Hand" IsReadOnly="True" FontFamily="Arial" Name="bar" > <TextBox.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <LinearGradientBrush.RelativeTransform> <TransformGroup> <ScaleTransform CenterX="0.5" CenterY="0.5"/> <SkewTransform CenterX="0.5" CenterY="0.5"/> <RotateTransform CenterX="0.5" CenterY="0.5"/> <TranslateTransform/> </TransformGroup> </LinearGradientBrush.RelativeTransform> <GradientStop Color="#FF091F34" Offset="1"/> <GradientStop Color="#FF002F5C" Offset="0.4"/> </LinearGradientBrush> </TextBox.Background> </TextBox> </Grid> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="true"> <Setter TargetName="bar" Property="Style" Value="{StaticResource MouseOverFocusStyle}" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <DataTemplate x:Key="CustomListData" DataType="{x:Type ListBoxItem}"> <Button Style="{StaticResource listButton}" /> </DataTemplate> </Window.Resources> <Window.DataContext> <ObjectDataProvider ObjectType="{x:Type local:ImageLoader}" MethodName="LoadImages" /> </Window.DataContext> <ListBox ItemsSource="{Binding}" Width="320" Background="#FF021422" BorderBrush="#FF1C4B79"> <ListBox.Resources> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}">Transparent</SolidColorBrush> <Style TargetType="{x:Type ListBox}"> <Setter Property="ItemTemplate" Value="{StaticResource CustomListData }" /> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /> </Style> </ListBox.Resources> </ListBox>

    Read the article

  • WPF DataTemplateKey can not find ListBox key

    - by Ryan
    I am fairly new to WPF and am having trouble getting the DataTemplateKey to find my ListBox. <Window.Resources> <ControlTemplate x:Key="FocusTemplate" > <Rectangle Fill="Azure" Width="290" Height="55" /> </ControlTemplate> <Style x:Key="FocusStyle" TargetType="{x:Type Control}"> <Setter Property="Template" Value="{StaticResource FocusTemplate}"/> </Style> <Style TargetType="ListBoxItem"> <EventSetter Event="GotFocus" Handler="ListItem_GotFocus"></EventSetter> </Style> <DataTemplate DataType="{x:Type TextBlock}"> </DataTemplate> <DataTemplate x:Key="CustomListData" DataType="{x:Type ListBox}"> <Border BorderBrush="Black" BorderThickness="1" Margin="-2,0,0,-1"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="55*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RenderTransform> <TransformGroup> <ScaleTransform ScaleX="1" ScaleY="1"/> <SkewTransform AngleX="0" AngleY="0"/> <RotateTransform Angle="0"/> <TranslateTransform X="0" Y="0"/> </TransformGroup> </Grid.RenderTransform> <!--<ScrollViewer x:Name="PART_ContentHost" />--> <TextBox Width="290" TextAlignment="Left" VerticalContentAlignment="Center" BorderThickness="0" BorderBrush="Transparent" Foreground="#FF6FB8FD" FontSize="18" FocusVisualStyle="{StaticResource FocusStyle}" Name="editingBox" TextWrapping="Wrap" Text="{Binding .}" Grid.Column="1" Grid.Row="1" MinHeight="55" Cursor="Hand" IsReadOnly="True" > <TextBox.Background> <LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> <LinearGradientBrush.RelativeTransform> <TransformGroup> <ScaleTransform CenterX="0.5" CenterY="0.5"/> <SkewTransform CenterX="0.5" CenterY="0.5"/> <RotateTransform Angle="0" CenterX="0.5" CenterY="0.5"/> <TranslateTransform/> </TransformGroup> </LinearGradientBrush.RelativeTransform> <GradientStop Color="#FF2D4984"/> <GradientStop Color="#FF182D56" Offset="0.042"/> </LinearGradientBrush> </TextBox.Background> </TextBox> </Grid> </Border> </DataTemplate> <Style TargetType="{x:Type ListBox}"> <Setter Property="ItemTemplate" Value="{StaticResource CustomListData }" /> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /> </Style> </Window.Resources> <Window.DataContext> <ObjectDataProvider ObjectType="{x:Type local:ImageLoader}" MethodName="LoadImages" /> </Window.DataContext> <ListBox ItemsSource="{Binding}" Width="320" Background="#FF021422" BorderBrush="#FF1C4B79"> <ListBox.Resources> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}">Transparent</SolidColorBrush> </ListBox.Resources> </ListBox> The following code will find a TextBlock var key = new System.Windows.DataTemplateKey(typeof(TextBlock)); var r = (DataTemplate)this.FindResource(key); However, when I change the type to ListBox, the key can not be found. What have I missed? Thanks Ryan

    Read the article

  • Member "TextTrimming" is not recognized in Expression Blend?

    - by emalamisura
    So I am using Silverlight 4.0 I have the following code but its giving me the following error: "The member "TextTrimming" is not recognized or is not accessible", but it works fine when I run in Visual Studio 2010. <TextBlock Margin="0,30,28.789,50.455" TextWrapping="Wrap" TextTrimming="WordEllipsis" HorizontalAlignment="Right" Width="117" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" d:LayoutRounding="Auto" Text="This is some text in a sticky note for the sake of making sure that the text will fit and that the user can see all the necessary details that are going to be available and stuff" LineHeight="-1" FontWeight="Normal"> <TextBlock.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform AngleX="8"/> <RotateTransform/> <TranslateTransform/> </TransformGroup> </TextBlock.RenderTransform>

    Read the article

  • Determine the width of the vertical scroll bar in a ScrollViewer

    - by juharr
    I'm using a ScrollViewer to display an Image. The Image has a ScaleTransform set as one of it's LayoutTransforms. I've got it setup to fit the width of the image into the ActualSize of the ScrollViewer. My problem is that if the image height requires the vertical scrollbar to be present (I have it set to Auto) then my image is scaled just a little bit to much. I know how to determine if the scrollbar would be present and how to get the correct scale, but I cannot figure out how to determine what the actual width of the scrollbar is. I guess I could just guess at it, but I'd like something that would work if I later add styles to my application that would result in the scrollbars being a different size. Additionally I'm also doing Fit to Height and would need to get the Height of the horizontal scrollbar when it would be visible (I'm assuming that the answer to getting the width of the vertical scrollbar would make getting the height of the horizontal scrollbar obvious).

    Read the article

  • Path element of Siverlight issue

    - by George2
    Hello everyone, Suppose I have the following XAML code, my confusions are, (1) I do not know the exact meaning of Data attribute, especially items starts with letter M/C, (2) there is no special configuration for TransformGroup (all using default settings), why put the TransformGroup here? <Path Height="2.75" Width="2.75" Data="M2.75,1.375 C2.75,2.1343915 2.1343915,2.75 1.375,2.75 C0.61560845,2.75 0,2.1343915 0,1.375 C0,0.61560845 0.61560845,0 1.375,0 C2.1343915,0 2.75,0.61560845 2.75,1.375 z" Fill="#FF9F9B9B" Stretch="Fill" Stroke="#FF000000" StrokeThickness="0" Canvas.Top="7" x:Name="p3"> <Path.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform/> <TranslateTransform/> </TransformGroup> </Path.RenderTransform> </Path> thanks in advance, George

    Read the article

  • WPF Animate a Matrix using interpolation

    - by Mark
    I'm having a issue with my application that is using touch gestures to scale, translate and rotate my scene. I was using a TransformGroup which contained TranslateTransform, ScaleTransform and a RotateTransform but I could not get the movement correct, it always jumps and skips, so I moved to a MaxtrixTransform which I was able to use much easier to get my scene to be zoomable, rotatable and panable nicely. However, what I later found out was that you cannot animate smoothly (using interpolation) the values of a Matrix, for what reason I have no idea, but its part of the MSDN doco and the properties of the Matrix are not dependency properties anyways... Has anyone had any luck animating a matrix to make it smooth? The only idea(s) I have had is to animate a few different, custom DP which all have callbacks that I update the matrix from OR To convert the matrix to a set of Transform objects that I then animate and then afterwords convert back. Is there a smarter way to do this?

    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 Animate a Maxtrix using interpolation

    - by Mark
    Im having a issue with my application that is using touch gestures to scale, translate and rotate my scene. I was using a TransformGroup which contained TranslateTransform, ScaleTransform and a RotateTransform but I could not get the movement correct, it always jumps and skips, so I moved to a MaxtrixTransform which I was able to use much easier to get my scene to be zoomable, rotatable and panable nicely. However, what I later found out was that you cannot animate smoothly (using interpolation) the values of a Matrix, for what reason I have no idea, but its part of the MSDN doco and the properties of the Matrix are not dependency properties anyways... Has anyone had any luck animating a maxtrix to make it smooth? The only idea(s) I have had is to animate a few different, custom DP which all have callbacks that I update the Matrix from OR To convert the Maxtix to a set of Transform object that I then animate and then afterwords convert back. Is there a smarter way to do this?

    Read the article

  • Change the image height and width based on the scale?

    - by user281947
    I want to resize the image height and width after setting its scale, below is what i am doing : <Image x:Name="img" Source="sii.PNG" > <Image.RenderTransform> <ScaleTransform x:Name="scale" /> </Image.RenderTransform> </Image> below is the cs code : void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { scale.ScaleX = scale.ScaleY =e.NewValue; //here i have to change the height and width of an image }

    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

  • Memory leak while asynchronously loading BitmapSource images

    - by harry
    I have a fair few images that I'm loading into a ListBox in my WPF application. Originally I was using GDI to resize the images (the originals take up far too much memory). That was fine, except they were taking about 400ms per image. Not so fine. So in search of another solution I found a method that uses TransformedBitmap (which inherits from BitmapSource). That's great, I thought, I can use that. Except I'm now getting memory leaks somewhere... I'm loading the images asynchronously using a BackgroundWorker like so: BitmapSource bs = ImageUtils.ResizeBitmapSource(ImageUtils.GetImageSource(photo.FullName)); //BitmapSource bs = ImageUtils.GetImageSource(photo.FullName); bs.Freeze(); this.dispatcher.Invoke(new Action(() => { photo.Source = bs; })); GetImageSource just gets the Bitmap from the path and then converts to BitmapSource. Here's the code snippet for ResizeBitmapSource: const int thumbnailSize = 200; int width; int height; if (bs.Width > bs.Height) { width = thumbnailSize; height = (int)(bs.Height * thumbnailSize / bs.Width); } else { height = thumbnailSize; width = (int)(bs.Width * thumbnailSize / bs.Height); } BitmapSource tbBitmap = new TransformedBitmap(bs, new ScaleTransform(width / bs.Width, height / bs.Height, 0, 0)); return tbBitmap; That code is essentially the code from: http://rongchaua.net/blog/c-wpf-fast-image-resize/ Any ideas what could be causing the leak?

    Read the article

  • XAML, binding Width and Height properties to the same properties of other control

    - by JAG
    I'm trying to create a reflection effect and it's working great except that I have to hard-code some values. This is my XAML: <Grid> <Grid.RowDefinitions> <RowDefinition Height="60"/> <RowDefinition /> <RowDefinition Height="80"/> </Grid.RowDefinitions> <StackPanel Grid.Row="1" VerticalAlignment="Center"> <UserControl x:Name="CurrentPresenter" /> <Border Width="500" Height="200" > <Border.Background> <VisualBrush Visual="{Binding ElementName=CurrentPresenter}" > <VisualBrush.Transform> <TransformGroup> <ScaleTransform ScaleX="1" ScaleY="-1" CenterX="500" CenterY="99" /> </TransformGroup> </VisualBrush.Transform> </VisualBrush> </Border.Background> <Border.OpacityMask> <LinearGradientBrush StartPoint="0,0" EndPoint="0,0.6"> <GradientStop Offset="-0.6" Color="Black"></GradientStop> <GradientStop Offset="0.6" Color="Transparent"></GradientStop> </LinearGradientBrush> </Border.OpacityMask> </Border> </StackPanel> </Grid> I've tried to replace Border's Width="500" and Height="200" by Width="{Binding ElementName=CurrentPresenter, Path=Width}" and Height="{Binding ElementName=CurrentPresenter, Path=Height}" but it doesn't seem to work. Wha's wrong with this code? UPDATE: If I set Width and Height here: <UserControl x:Name="CurrentPresenter" Height="200" Width="500" /> It works as expected. However it doesn't work if I set those values in the UserControl XAML. Any ideas?

    Read the article

  • WPF - data binding trigger before content changed

    - by 0xDEAD BEEF
    How do i create trigger, which fires BEFORE binding changes value? How to do this for datatemplate? <ContentControl Content="{Binding Path=ActiveView}" Margin="0,95,0,0"> <ContentControl.Triggers> <--some triger to fire, when ActiveView is changing or has changed ?!?!? --> </ContentControl.Triggers> public Object ActiveView { get { return m_ActiveView; } set { if (PropertyChanging != null) PropertyChanging(this, new PropertyChangingEventArgs("ActiveView")); m_ActiveView = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("ActiveView")); } } How to do this for DataTemplate? <DataTemplate DataType="{x:Type us:LOLClass1}"> <ContentControl> <ContentControl.RenderTransform> <ScaleTransform x:Name="shrinker" CenterX="0.0" CenterY="0.0" ScaleX="1.0" ScaleY="1.0"/> </ContentControl.RenderTransform> <us:UserControl1/> </ContentControl> <DataTemplate.Triggers> <-- SOME TRIGER BEFORE CONTENT CHANGES--> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="shrinker" Storyboard.TargetProperty="ScaleX" From="1.0" To="0.8" Duration="0:0:0.3"/> <DoubleAnimation Storyboard.TargetName="shrinker" Storyboard.TargetProperty="ScaleY" From="1.0" To="0.8" Duration="0:0:0.3"/> </Storyboard> </BeginStoryboard> </-- SOME TRIGER BEFORE CONTENT CHANGES--> </DataTemplate.Triggers> </DataTemplate> How to get notification BEFORE binding is changed? (i want to capture changing Visual component to bitmap and create sliding view animation)

    Read the article

  • Invert the 1bbp color under a rectangle.

    - by Scott Chamberlain
    I am working with GDI+, the image I am working with is a 1bbp image. What i would like to do is draw a rectangle on the image and everything under that rectangle will be inverted (white pixels will become black and black pixels become white). All of the sample code I have seen is for 8 bit RGB color scale images, and I don't think the techniques they use will work for me. Here is the code I have so far. This is the parent control, one of the Epl2.IDrawableCommand's will be the command that does the inverting. protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (Label != null) { using (Bitmap drawnLabel = new Bitmap((int)((float)Label.LabelHeight * _ImageScaleFactor), (int)((float)Label.LableLength *(int) _ImageScaleFactor), System.Drawing.Imaging.PixelFormat.Format1bppIndexed)) { using (Graphics drawBuffer = Graphics.FromImage(drawnLabel)) { drawBuffer.ScaleTransform(_ImageScaleFactor, _ImageScaleFactor); foreach (Epl2.IDrawableCommand cmd in Label.Collection) { cmd.Paint(drawBuffer); } drawBuffer.ResetTransform(); } drawnLabel.RotateFlip(Rotation); pbLabelDrawArea.Size = drawnLabel.Size; using (Graphics drawArea = pbLabelDrawArea.CreateGraphics()) { drawArea.Clear(Color.White); drawArea.DrawImage(drawnLabel, new Point(0, 0)); } } } } What should I put in the Paint(Graphic g) for this command?

    Read the article

  • coordination transform issue in Silverlight

    - by George2
    Hello everyone, I am using Silverlight 3.0 + .Net 3.5 + VSTS 2008 + C# to develop silverlight application based on ASP.Net. I am very confused about what are the function of "TranslateTransform" and "RenderTransformOrigin" in the following code snippet? BTW: I roughly understand RenderTransformOrigin means move an UI element in x-axis and y-axis by some offset, is that correct? Move the whole UI element? <Grid Margin="-1,0,100,0" x:Name="controlsContainer" Height="35" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Bottom"> <Grid.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform/> <TranslateTransform Y="0"/> </TransformGroup> </Grid.RenderTransform> <Rectangle Margin="0,0,0,0" Height="35" VerticalAlignment="Top" Fill="#97000000" Stroke="#00000000" RenderTransformOrigin="0.5,0.5"/> <VideoPlayer:mediaControl Height="35" Margin="1,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Top" x:Name="mediaControls" Visibility="Visible"/> </Grid> thanks in advance, George

    Read the article

< Previous Page | 1 2 3  | Next Page >