Change KinectTileButton selected color - xaml

I am displaying a clipped image (round shape) inside a KinectTileButton. The problem is that I don't know how to change the Selected behavior. By default, when the button gets clicked, the entire area gets darker and I get to see the corners of the square. I want to change the Selected state to transparent so I don't see the corners of the square (as I have a circle inside).
<k:KinectTileButton Background="Transparent" Width="500" Height="500" Click="ContactClick">
<Grid Height="500" Width="500">
<Image Source="/Namespace;component/Resources/Images/Image.png" Width="450" Height="450" x:Name="ContactStream">
<Image.Clip>
<EllipseGeometry RadiusX="220" RadiusY="220" Center="225,225"/>
</Image.Clip>
</Image>
</Grid>
</k:KinectTileButton>

Related

Xamarin Forms: ImageButton border ignored on Android

I have a StackLayout containing some ImageButtons, the buttons have a BorderWidth of 5.
On UWP, the border appears with the image scaled to fit inside. On Android, the border doesn't appear at all, and the image flows into it space.
UWP (correct):
Android (no border):
My XAML looks like this
<StackLayout
x:Name="titlebar"
Orientation="Horizontal"
BackgroundColor="{x:DynamicResource TitleBarColor}">
...
<ImageButton
x:Name="menu"
HeightRequest="25" WidthRequest="25"
HorizontalOptions="End"
BorderWidth="5"
BackgroundColor="{x:DynamicResource TitleBarColor}"
Source="{local:ImageResource CloudTest.Assets.icons.more_menu_white.png}"
Clicked="OnMenuClicked" />
</StackLayout>
In Android, I've found that it only works if you set both BorderWidth and BorderColor(could not Transparent).
and you also could set the Padding or Marginto the ImageButton to achieve to the effect.
<ImageButton
x:Name="menu"
HeightRequest="25" WidthRequest="25"
HorizontalOptions="End"
Padding ="5" //or Margin ="5"
BackgroundColor="{x:DynamicResource TitleBarColor}"
Source="{local:ImageResource CloudTest.Assets.icons.more_menu_white.png}"
Clicked="OnMenuClicked" />
Update (The yellow area is your ImageButton):
When using Margin,refers to the distance between the control and a sibling control :
Padding ,refers to the internal content of the control, such as the margin of the text/image distance from the control
so when you use the padding,you will see the space inside the image and when you use the margin,the space outside the image .

UWP CommandBar moves vertically when IsOpen changes

I have come across a layout / template problem with CommandBar of which symptoms are seen in several pages:
UWP - CommandBar blank space under Buttons
https://github.com/microsoft/microsoft-ui-xaml/issues/1024
It seems that the UWP CommandBar elements inside the CommandBar have an actual height of 44px, which is cropped in a control of 40px.
When IsOpen="False", the AppBarButtons are vertically centered and the bottom 4px of the CommandBar.Content section is not shown
When IsOpen="Top", the AppBarButtons are shifted up, an ugly gap appears under them and the bottom 4px of the CommandBar.Content section is suddenly shown
Besides the ugly gap, it makes it very difficult to correctly vertically center elements in CommandBar.Content.
About the vertical position of the CommandBar
When the CommandBar is at the top of the Page, the CommandBar itself does not vertically resize.
When the CommandBar is at the bottom of the Page, the CommandBar itself grows vertically with 4px.
In all cases, the other symptoms happen
At bottom of page
The red line visualizes the bottom 4px of the CommandBar.Content section. Also, with the Reveal effect to the left of the mouse cursor you can see that the buttons shift up. The whole CommandBar grows vertically
At top of page
Trying to vertically align the content (hint: does not work)
Question
Is there any way to workaround this issue? Microsoft has qualified this more than a year ago as something they might fix in WinUI 3 which is far away.
Bug repro repository
https://github.com/hansmbakker/CommandBar.BugRepro
Relevant code to reproduce
<Page x:Class="CommandBar.BugRepro.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CommandBar.BugRepro"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.BottomAppBar>
<CommandBar
VerticalContentAlignment="Bottom"
Background="#BB555555"
DefaultLabelPosition="Right">
<AppBarButton Icon="Back"
Label="Back" />
<AppBarButton Icon="Save"
Label="Save" />
<AppBarSeparator />
<AppBarButton Label="Title" />
<AppBarButton Label="Description" />
<AppBarButton Label="Pictures"
Icon="Pictures" />
<CommandBar.Content>
<Rectangle Fill="Red"
Height="4"
Width="200" />
</CommandBar.Content>
<CommandBar.SecondaryCommands>
<AppBarButton Icon="Setting"
Label="Settings">
<AppBarButton.KeyboardAccelerators>
<KeyboardAccelerator Modifiers="Control"
Key="I" />
</AppBarButton.KeyboardAccelerators>
</AppBarButton>
</CommandBar.SecondaryCommands>
</CommandBar>
</Page.BottomAppBar>
<Grid>
</Grid>
</Page>
UWP CommandBar moves vertically when IsOpen changes
During the testing, AppBarSeparator cause this behavior. Currently there is a work around that could fix this, please give AppBarSeparator specific height less than 40px.
<AppBarSeparator Height="40"/>

Xamarin Child Frame Overflow On Parent Corner Radius

I have a Xamarin Forms project with a card based interface where each card has a Corner Radius of 1 and padding 0. Within the card, the top element is a Heading control, with margin of 0, consisting of a frame with a background colour and a label within that.
The problem is since the Heading control does not have rounded corners, the corners which meet the corners of the Card will overrun and render outside of the Card which doesn't look right.
Is there any way to tell the Xamarin XAML renderer to appropriately cut off the corners of a child when the parent has rounded corners?
Here's a picture to show what I mean. The green pointed corners are rendered outside of the parent card.
To get the same result with Xamarin.Forms version 3.1.583944 for the background and rounded corners on Android, iOS, and UWP, try this XAML:
<OnPlatform x:TypeArguments="View">
<On Platform="UWP">
<Frame CornerRadius="20" OutlineColor="Black" Padding="0" Margin="12,0" HeightRequest="40">
<StackLayout BackgroundColor="Green">
<Label Text="BackgroundColor in StackLayout" Margin="20,0" />
</StackLayout>
</Frame>
</On>
<On Platform="Android, iOS">
<Frame CornerRadius="20" OutlineColor="Black" BackgroundColor="Green" Padding="0" Margin="12,0" HeightRequest="40">
<StackLayout>
<Label Text="BackgroundColor in Frame" Margin="20,0" />
</StackLayout>
</Frame>
</On>
</OnPlatform>
It seems that neither platform seems to produce the same result, possibly by native platform design (i.e. Android produce background inside the rounded corners in both cases above, iOS produce background inside rounded corners when BackgroundColor is set in Frame, UWP produce background inside rounded corners when BackgroundColor is set in StackLayout).
Please note that there are reported some issues with UWP on Frame CornerRadius.

Can't set InkToolbarRulerButton background as transparent using InkToolbar

I create a ink toolbar, and the initial controls are all except pens.
I can set the eraser button's background as transparent, but apply to the ruler button.
Is this a ink toolbar bug?
<InkToolbar Background="Transparent" InitialControls="AllExceptPens" TargetInkCanvas="{x:Bind inkCanvas}">
<InkToolbarEraserButton Background="Transparent"/>
<InkToolbarRulerButton Background="Transparent"/>
</InkToolbar>
The rule button is actually the InkToolbarStencilButton in the visual tree, not InkToolbarRulerButton. So that update your code snippet as follows will work.
<InkToolbar
Background="Transparent"
InitialControls="AllExceptPens"
<InkToolbarEraserButton Background="Red" />
<!--<InkToolbarRulerButton Background="Red" Foreground="Blue" />-->
<InkToolbarStencilButton Background="Red"></InkToolbarStencilButton>
</InkToolbar>

Windows Phone 8.1 XAML Image inside ToggleButton adds mystery padding

I'm working with a toggle button and rather than show text I want to show an image so I have this:
<ToggleButton Grid.Column="1" IsChecked="true" MinWidth="50" MinHeight="0" BorderThickness="0" HorizontalAlignment="Center">
<Image Source="ms-appx:///Assets/Icons/phonebutton.png" Stretch="None" RenderTransformOrigin="0.5,0.5" Margin="0">
<Image.RenderTransform>
<CompositeTransform ScaleX="0.5" ScaleY="0.5"/>
</Image.RenderTransform>
</Image>
</ToggleButton>
I have the transform to make the image a bit smaller so it's "inside" the button instead of filling it.
However, no matter what I do the button has a large padding around the image, even though the image itself has no margins or padding. I've set margin=0 on everything but the ToggleButton insists on putting space around the image, so the button is larger than it needs to be and cuts off inside the grid row it's in (which has a height="*")
I want the toggle button to "shrink" to fit in the row but still show the full image inside ...
while typing this the autosuggest found this link ToggleButton does not fill the area(windows phone) and by adding the style PhoneTouchTargetOverhang it does look better but then cuts off the image at the bottom unless I add negative padding to the togglebutton.
Anyone have any idea what I'm doing wrong?
Is there any way to disable it?
I have added the following margin to an image of 512x512:
<Image Source="/Assets/award4.png" Stretch="None" RenderTransformOrigin="0.5,0.5" Margin="-100,0,-100,0">
<Image.RenderTransform>
<CompositeTransform ScaleX="0.5" ScaleY="0.5"/>
</Image.RenderTransform>
</Image>
And it fits centered