How to bind Grid RowDefinition's Height in X.F? - xamarin.forms

I have this binding in my XAML
<RowDefinition Height="{Binding HasValue, Converter={StaticResource BoolToIntConverter}, ConverterParameter=33}" />
but it doesn't seem to work as straight-forward as I assumed. When rendering the page the height of the row is evaluated to a star value actually as opposed to 33.
Any trick I am missing?

The binding works if the converter returns a value of type GridLength explicitly...

Related

Uno Material Card Formatting

I am using the Uno Material Card in my app. Recently there was a change to Uno.Material in the way it was initialized. I implemented that- with some help from #sbilogan in this response: Uno Material Initialization. However- the text in my cards no longer have the formatting. I tried adding back in the template to format the text- but it did not work. I am guessing something is being changed here- but not sure how to proceed. Here is my sample code and screenshots:
<material:Card x:Name="appInfoCard" HeaderContent="App Information"
SubHeaderContent="Tap to see more"
SupportingContent="App: "
Style="{ThemeResource MaterialOutlinedCardStyle}"
MediaContent="Example"
Foreground="{ThemeResource SubPageTextColor}"
Background="{ThemeResource cardBackground}">
<material:Card.MediaContentTemplate>
<DataTemplate>
<StackPanel Padding="10">
<Omitted for clarity>
</StackPanel>
</DataTemplate>
</material:Card.MediaContentTemplate>
</material:Card>
The code with the full template(I had to use this at one point- but the a change was merged into Uno Material so I did not have to use it anymore)
<material:Card.HeaderContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"
Margin="16,14,16,0"
Style="{ThemeResource MaterialHeadline6}" />
</DataTemplate>
</material:Card.HeaderContentTemplate>
<material:Card.SubHeaderContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"
Margin="16,0,16,14"
Style="{ThemeResource MaterialBody2}" />
</DataTemplate>
</material:Card.SubHeaderContentTemplate>
The top image was made with Uno Material build 774. The bottom was with 782.
It turns out that in my MaterialColorOverridePallette.xaml- I had the following set:
Green
Green
For some reason- it did not interfere with the formatting before 774. After 774- it removes the formatting from these categories for some reason. Removing them caused them to work as expected in 802 and beyond. Hopefully this helps someone else.

Change Color in DatePicker

When I try to create a DatePicker it appears all white, and only the selected date is black which I changed through the Textcolor property. The rest of the graphics appear fuchsia in my case. How can I change the rest?
This is a known bug in Forms with Dark Theme.
There was a workaround posted recently
This is a super-ugly hack, but it solved the problem for me. Based on what #stefanbogaard86 suggested, I tried using Visual="Material", but the problem I ran into was that the DatePicker entry box didn't match the rest of the form. But, he's right that using Material did fix the issue with the picker rendering. So, I found this to get the best of both visuals:
<AbsoluteLayout>
<DatePicker
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All"
Date="{Binding Birthdate}"
Format="yyyy-MM-dd"
Style="{DynamicResource DatePicker}" />
<DatePicker
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All"
Date="{Binding Birthdate}"
Format="yyyy-MM-dd"
Opacity="0"
Style="{DynamicResource DatePicker}"
Visual="Material" />
</AbsoluteLayout>
The first picker is what we want to show in the form. The second one is what we want to be clickable and show the full date picker, but we don't it shown in the form, so its opacity is zero. They're both bound to the same property, so when you change the value they both work.
Like I said, this is super-ugly, but it works.

Xamarin Forms Disable NamedSize font doesn't work

I try run this from Xamarin.Forms.Sample repo https://github.com/xamarin/xamarin-forms-samples
Under folder UserInterface/PlatformSpecifics with :
ios:Application.EnableAccessibilityScalingForNamedFontSizes="false"
This flag is set to disable scaling of fontsize, however when I go to ios settings Larger Font Size and increase the size, look like that disable doesn't work at all, what do I miss here? or is it a bug?
Check this PR , it adds the functionality of disable accessibility sizing for named font sizes .
You can see in that class it affects the font size returned from GetNamedSize method, and check the following screen shot you could find out those controls which will be affected.
So PlatformSpecifics API only works on some specifc controls , it does not affect ViewCell and TableSection in your scenario .
As a workaround , you could replace TextCell with ViewCell and place a Label inside it ,something like
<ViewCell>
<Label Text="fdhfihdif">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding}" CommandParameter="{}"/>
</Label.GestureRecognizers>
</Label>
</ViewCell>
Consider raising feature request on github what you want .

Binding DataGrid column headers in Silverlight

I've seen quite a few unanswered posts on this topic, yet I'm still inclined to believe someone on here as figured this out and is holding out on the rest of us.
I have a DataGrid that contains a mix of template columns and text columns. I just need a way of binding the headers to properties in the viewmodel so that I can use different strings for different languages.
I've seen WPF datagrid header text binding and every post linked from it. None of the methods suggested here work in Silverlight.
Does no one have any ideas?
I've recently spent a bit of time working on this too, here is how I got it working for other peoples benefit.
First declare namespace up top so I can specify it short hand in the xaml.
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
Then I declare header styles as static resources up top to keep the datagrid xaml clean:
<navigation:Page.Resources>
<Style x:Key="NameStyle" TargetType="sdk:DataGridColumnHeader">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding Path=LocalizedStrings.Name, Source={StaticResource Language}}"/>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DescriptionStyle" TargetType="sdk:DataGridColumnHeader">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding Path=LocalizedStrings.Description, Source={StaticResource Language}}"/>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</navigation:Page.Resources>
Then in your datagrid xaml you can simply set your DataGridTextColumns Header style to your static resource header style.
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Width="Auto" FontSize="11" MinWidth="100" Binding="{Binding Name}" HeaderStyle="{StaticResource NameStyle}" />
<sdk:DataGridTextColumn Width="1*" FontSize="11" Binding="{Binding Description}" HeaderStyle="{StaticResource DescriptionStyle}" />
</sdk:DataGrid.Columns>
My original solution was from this post: Dynamically setting the Header text of a Silverlight DataGrid Column
Just tidied it up a bit as I had 15 column headers to set.

Checkbox does not display properly in Flex

I have a checkbox that does not render as a checkbox and would be displayed as something similar to a button. However, it behaves like a checkbox where I can select it and the handler works with the firing event.
Here is my checkbox. I also tried it outside the or , but it has the same behavior. There is no CSS related to checkbox or the part that I am working on. I am using Flex 4.5 though.
1- Has anybody encounter such a problem?
2- Is there any way to enforce the layout inside a container and item renderer?
<mx:HBox>
<mx:CheckBox id="Test"
label="Label"
fontWeight="bold"
change="Test_changeHandler(event)"/>
</mx:HBox>
If you're using Flex 4.5, why are you using Flex 3 components? Change this to spark components and everything should be much better:
<s:HGroup>
<s:CheckBox id="Test"
label="Label"
fontWeight="bold"
change="Test_changeHandler(event)"/>
</s:HGroup>
mx:CheckBox extends mx:Button, so if you put added css that skinned mx:Button, mx:CheckBox would also get it. It's a shortcoming of flex 3 skinning. You can workaround by explicitly setting the mx:CheckBox skin.
Edit: try this
<mx:HBox>
<mx:CheckBox id="Test"
label="Label"
fontWeight="bold"
skin="{mx.skins.spark.CheckBoxSkin}"
change="Test_changeHandler(event)"
/>
</mx:HBox>
This happend to me also. Fix was to use a mx:Container as parent instead of FlexGlobals.application on the popup component.
for the second question:
I had exactly the same problem and i forced it to take the "original" skin with:
var skinClass:Class = mx.skins.spark.CheckBoxSkin;
theCheckBoxInstance.setStyle("skin", skinClass);
Because in my case the CheckBox was an ItemRenderer for a DataGrid, I've put it in the overridden createChildren methode right after the super call..
I have no explication why this happens. I encountered it in an old monster project where I was charged to make some changes...

Resources