I need to display a text "welcome" on the right-bottom corner of a canvas with red colour
this is my xaml code
<Canvas x:Name="imageOne" Background="White" Width="480" Height="800" >
</Canvas>
please help me
Canvas defines an area within which you have to explicitly position TextBlock element by coordinates relative to the Canvas area. Means you have to do absolute positioning inside a Canvas.
If you really want to use a Canvas, you can better take a transparent Grid inside it and put a TextBlock inside that Grid.
Example:
<Canvas x:Name="imageOne" Background="White" Width="480" Height="800">
<Grid Width="480" Height="800">
<TextBlock Text="Visifire" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
</Grid>
</Canvas>
Please make sure that the Grid size is same as Canvas size.
Related
PersonPicture is a control offered in Microsoft's Universal Windows Platform.
It looks great, which is why I'm trying to use it to display a user's initials with a background color.
The problem is that when I set the control's background to a color, the background is not changed on the display.
<PersonPicture Initials="JF"
Background="Red"/>
In the above code, the Background still remains the default, while everything else is updated.
Please if you have been able to set the background color, share how you've done it!
I found the template for the PersonPicture through this question: How to get all Controls' ControlTemplates Programmatically?(UWP)
The PersonPicture ignores its Background property and uses a couple of brushes that make up the colors of the control depending on Dark/Light theme and some hard coded values.
It draws an ellipse/circle and thus shows its container's color in the four corners.
Assuming you want to set the color in the square that contains the picture you could do this:
<Grid Background="Green">
<Grid HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Red">
<PersonPicture />
</Grid>
</Grid>
The first grid represents a page. The second grid tightly wraps around the PersonPicture:
Note how the personpicture is somewhat transparent and shows the color of the grid. The color that the template uses for the ellipse is #77FFFFFF
So you could take it a step further by adding an ellipse:
<Grid Background="Green">
<Grid HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Red">
<Ellipse Fill="White"/>
<PersonPicture />
</Grid>
</Grid>
This allows you to control the color of the picture somewhat by setting the color of the ellipse:
Do note that it still mixes the PersonPicture with the background so you cannot set it to black:
<Grid Background="Green">
<Grid HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Red">
<Ellipse Fill="Black" />
<PersonPicture />
</Grid>
</Grid>
Shows:
And finally, you could copy the template (see: How to get all Controls' ControlTemplates Programmatically?(UWP))
and adjust it to use the Background property.
I want to have something like shown in this screenshot here:
The Edit part should be in the bottom of the circle and should be tappable. How can I achieve this in UWP xaml?
You can just "draw over" a Button to the Ellipse in a layout control eg. in a Grid. Something like this:
<Grid Height="100" Width="100" Background="Aqua">
<Ellipse Fill="Red"/>
<Button Background="Aqua" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Content="Edit" Tapped="Button_Tapped"/>
</Grid>
Let's say we have a grid with a TextBlock in it. Now if I do some RenderTransform which makes the TextBlock appear outside of the grid, the TextBlock is still visible. My question is simple: how to automatically hide the part of the TextBlock that's outside of the grid? (In other words, how to make the grid act like a visual bound of its child?)
You can use a clipping mask that matches the bounds of the parent element:
<Border Height="200" Width="200" BorderThickness="1" BorderBrush="Black" >
<Border.Clip>
<RectangleGeometry Rect="0,0,200,200"></RectangleGeometry>
</Border.Clip>
<TextBlock Text="Foo">
<TextBlock.RenderTransform>
<TranslateTransform X="180"></TranslateTransform>
</TextBlock.RenderTransform>
</TextBlock>
</Border>
In WPF you don't need to do that manually, just set ClipToBounds="True"
I've created a simple user control for my xaml project, but as you can see from my image i cant seem to be able to do certain things.
Ignore the red line, its the size of the control for illustrate its size.
It's placement should be middle of the screen:
<Client:TileMenu HorizontalAlignment="Center" VerticalAlignment="Center" Name="TileOverlayMenu" Background="Azure" BorderBrush="Aquamarine" BorderThickness="3" />
And as you see its background color should be "Azure" with a blueish border of 3.
Why is this?
In the background I have a Canvas:
<Grid x:Name="ContentPanel" Grid.Row="0" Margin="12,0,12,0">
<Canvas Name="GameCanvas">
<Canvas.RenderTransform>
<CompositeTransform x:Name="CanvasRenderTransform" />
</Canvas.RenderTransform>
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener DragStarted="GestureListener_DragStarted" DragDelta="GestureListener_DragDelta" Tap="GestureListener_Tap" PinchStarted="GestureListener_PinchStarted" PinchDelta="GestureListener_PinchDelta"/>
</toolkit:GestureService.GestureListener>
</Canvas>
<Client:TileMenu HorizontalAlignment="Center" VerticalAlignment="Center" Name="TileOverlayMenu" Background="Azure" BorderBrush="Aquamarine" BorderThickness="3" />
</Grid>
As for my third problem, having the events in the canvas causes the Move slider to be interrupted, making me only able to push it a little each time :-/
In case TileMenu is a UserControl you would have to set these properties on the top level container in the UserControl's XAML as this defines the entire visual structure of the control.
You could bind to the appropriate values in the UserControl, however:
<UserControl x:Class="YourNamespace.TileMenu" ...
x:Name="tileMenu">
<Border BorderBrush="{Binding BorderBrush, ElementName=tileMenu}"
BorderThickness="{Binding BorderThickness, ElementName=tileMenu}">
<Grid>
...
</Grid>
</Border>
</UserControl>
I'm applying an EntranceThemeTransition animation to a TextBlock. The TextBlock has a style of PageHeaderTextStyle which has a RenderTransform in it. The issue I'm having is that the RenderTransform applies a Translation effect that doesn't actually render until after the animation is done playing. So, it looks weird because the animation scrolls the control in, and then suddenly the translation snaps the text in place. Does anyone know why this happens?
Is there a way to play the animation with the translation taken into account?
Transform:
<Setter Property="RenderTransform">
<Setter.Value>
<TranslateTransform X="-2" Y="8"/>
</Setter.Value>
</Setter>
TextBlock:
<TextBlock x:Name="pageTitle" Grid.Column="1" Text="{Binding Title}" Style="{StaticResource PageHeaderTextStyle}">
<TextBlock.Transitions>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</TextBlock.Transitions>
</TextBlock>
I just came up against exactly the same issue. The way to solve it is to nest the TextBlock one level away from the Grid with the transition on it, for example with a second Grid.
What happens is the transition applies a transform to each of its children, but any transform they may have had is replaced temporarily until after the animation completes, resulting in the nasty 'snap' when the original transform is applied afterwards.
In the following example, the transition will run, replacing the TextBlock's transform, and then after the transition ends the original transform will be applied. You see the 'snap':
<Grid Style="{StaticResource LayoutRootStyle}">
<TextBlock Text="Header" Style="{StaticResource PageHeaderTextStyle}"
Margin="0,0,0,40"/>
</Grid>
In the next example, the transition runs and the transform is applied to the Grid, leaving the TextBlock's transform unaffected. No 'snap':
<Grid Style="{StaticResource LayoutRootStyle}">
<Grid>
<TextBlock Text="Header" Style="{StaticResource PageHeaderTextStyle}"
Margin="0,0,0,40"/>
</Grid>
</Grid>
Hope this helps!
From your words it just seems like the EntranceThemeTransition animates the transform of your TextBlock. The simplest way around that would be to either put the entrance transition on a parent element, or put the transform on one. You could simply wrap your TextBlock in a Grid to do it.