WPF: power in xaml - xaml

I have text block with text "km2":
<TextBlock >Area(km2)</TextBlock>
How can I make "2" small and heigher such exponent I need view such on picture:

You can create Inlines, and set Typography.Variants appropriately.
<TextBlock><Run>Area(km</Run><Run Typography.Variants="Superscript">2</Run><Run>)</Run></TextBlock>

<TextBlock Text="Area(kmĀ²)"/>
Seems to work:

Related

Is it possible to make the background-colour of a Canvas field dependent on its value?

I want one datetime field's background colour to depend on its value. Like if a certain date is passed, the background changes to red.
Is there a way to make this in XAML?
I know there is no possibility of an "if" condition/instruction, but maybe you guys found some way to implement a similar function.
<Canvas Canvas.Left="893" Canvas.Top="208" Height="25" Width="99" Background="red" Panel.ZIndex="-1"/>
<assembly:FieldControl Canvas.Left="890" Canvas.Top="206" FieldControlType="DateControl" FormField="{x:Null}" Height="25" LabelColumnWidth="0" Refnr="123456789" ShowCaption="False" StateImageAlignment="Hidden" Width="106" FontSize="10" Foreground="DimGray"/>
this is my code so far. The Canvas-Part makes the Background go red.
I also tried to put the background property in the "FieldControl" but there it's useless.
EDIT:
After getting the information, that Data Binding could help me with this problem, i tested it like this:
<TextBox Canvas.Left="890" Canvas.Top="226" Name="Date" Width="99" Height="25" VerticalAlignment="Top" Text="{Binding ElementName=Date, Path = SelectedItem.Content, Mode = TwoWay, UpdateSourceTrigger = PropertyChanged}" Background="{Binding ElementName=Date, Path=SelectedItem.Content}">
But this is not the direction, i need. Do you have maybe any suggestion, how I can use Data binding to solve my problem?
Yes, it is possible. The concept you need to learn is XAML Data Binding.
You can implement the IValueConverter for this.
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/data-binding/converters
You can check the value on binding and return the background color.
how to give different text color for each item of listview in xamarin forms

UWP - Pivot IsTabStop not working as expected

I have a pivot that I am trying to keep from gaining focus when the user hits the tab key. I immediately tried to set IsTabStop to false. However this wasn't keeping a user from tabbing into the pivot. So I tried testing IsTabStop on two buttons and the behavior was exactly what I expected from the pivot.
Here is my xaml:
<Pivot IsTabStop="False">
<PivotItem Header="Test">
<StackPanel Spacing="10">
<Button Content="Button 1" IsTabStop="True"/>
<Button Content="Button 2" IsTabStop="False"/>
</StackPanel>
</PivotItem>
</Pivot>
Am I missing something here or is there a way around this?
Setting tab index to -1 only makes it first, try something like 1001.. In here they explain the issue you may be having but for RichTextBlock, there are various attributes available for it to set.. https://learn.microsoft.com/en-us/windows/uwp/design/accessibility/keyboard-accessibility
So what i ended up doing is overriding the default style on the pivot. I changed the "HeaderClipper" in the style to have IsTabStop="False", this fixed my problem.
The documentation for the default pivot style can be found at https://msdn.microsoft.com/en-us/library/windows/apps/mt299144.aspx

syncfusion uwp diagram mvvm command

I'm trying to add an gesture-command (del-key pressed) to the commandmanager of syncfusion's diagram.
I've tried something like:
<diagram:SfDiagram Grid.Row="1" Grid.Column="0"
Nodes="{Binding Nodes}"
Connectors="{Binding Connectors}"
Style="{StaticResource Diagram}"
>
<diagram:SfDiagram.Info>
<diagram:CommandManager>
<diagram:CommandManager.Commands>
<diagram:GestureCommand>
</diagram:GestureCommand>
</diagram:CommandManager.Commands>
</diagram:CommandManager>
</diagram:SfDiagram.Info>
</diagram:SfDiagram>
but i think I'm missing something here.
my question: how can I add an Event to the diagram-commandmanager using XAML and MVVM.

Setting today's date in XAML

I want to display today's date in XAML and then return that to my view model. So this shows it in XAML
<TextBlock Text="{Binding Source={x:Static sys:DateTime.Now}, StringFormat=dd/MMM/yyyy}"/>
but I want to return it in ModifiedDate, so I did this
<TextBlock x:Name="ModifiedDate" Text="{Binding Source={x:Static sys:DateTime.Now}, StringFormat=dd/MMM/yyyy}"/>
This doesn't work. I don't want to use datepicker. I want to use Pure XAML and do not wish to go to code. Any ideas?
you have to include this name space in your xaml..if you are not able to show date..
xmlns:sys="clr-namespace:System;assembly=mscorlib"
and if you want something different update your question..

C# Windows Store App - Find resource on xaml

If i have 9 TextBlock declared on the XAML file like this:
<TextBlock Name="cellText_00" Tag="0"/>
<TextBlock Name="cellText_01" Tag="1"/>
<TextBlock Name="cellText_02" Tag="2"/>
<TextBlock Name="cellText_20" Tag="3"/>
...
<TextBlock Name="cellText_22" Tag="8"/>
There is a way to interact with it from the .cs getting exactly the desired tag element?
For instance is it possible to give all the same name and get it in this way:
TextBlock tb = get(cellText,0);
where the first field is the name and the second one is the tag?
No, you can't use the same name for many controls.
However there is a workaround: using the FindName method:
http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.findname(v=vs.95).aspx
There Why can't I access a TextBox by Name with FindName()?
you can find an example and a solution related to namespaces issues.
FindName uses a string to retrieve the control. So you can do something like this: FindName("cellText_" + identifier); and take the element you need.
#Sandrouos, I don't think he's using the same name.
This blogpost explains it perfectly:
http://blog.jerrynixon.com/2012/09/how-to-access-named-control-inside-xaml.html