Before posting this issue I have searched and studied alot all answers given on StackOverflow but none did help me, so here I am ^^
My goal is to get the corresponsive of a Label in UWP using TextBox.
In TextBox property I have set "IsReadOnly="True"" but the "box" was still visible even if its property was set on Transparent.
So I have also added "IsEnabled="False"" Property and I have obtained my "label".
-
But, due to project requirements, I needed a white text and not the default-grey-text of uwp. So I have tried to set a custom style (following all answers from stackOverflow) until I have found this solution:
<Style x:Key="Titoli" TargetType="TextBox">
<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />
<Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="SelectionHighlightColor" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
<Setter Property="BorderThickness" Value="{ThemeResource TextControlBorderThemeThickness}" />
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
<Setter Property="ScrollViewer.HorizontalScrollMode" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollMode" Value="Auto" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
<Setter Property="Padding" Value="{ThemeResource TextControlThemePadding}"/>
<Setter Property="IsReadOnly" Value="True" />
<Setter Property="Background" Value="{x:Null}" />
<Setter Property="IsHitTestVisible" Value="False" />
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<Border x:Name="ContentElement" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
And obtaining this Preview (T1,T2,T3 ecc are the labels I am focusing):
But when I'll Debug, the app have this look:
So no textbox is "printed" out... I really can't figure out a solution (Also my custom bottons-images are disappeared!) Any suggestion?
I have also copy-pasted the full TextBox from here and modified but I can't retrieve the solution in the first screen in this way...
code snippet of Xaml.MainPage:
<Grid.ColumnDefinitions>
<!--Definisco quante colonne voglio e come siano definite -->
<ColumnDefinition Width="15*"/>
<!-- Colonna per AGGIUNTE SUCCESSIVE -->
<ColumnDefinition Width="15*"/>
<!-- Colonna per Box dati -->
<ColumnDefinition Width="*"/>
<!-- Colonna per il sito a lato -->
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<!--Definisco quante righe voglio e come siano definite -->
<RowDefinition Height="30*"/>
<!-- riga per definire spazio per box dati -->
<RowDefinition Height="15*"/>
<RowDefinition Height="15*"/>
</Grid.RowDefinitions>
<!-- *********************** Sezione display sonde **************************** -->
<!-- Sezione Unità di Misura -->
<TextBox Text="°C" TextWrapping="Wrap" IsEnabled="False" Margin="285,146,374,282" Style="{StaticResource Titoli}" Height="52" Width="38" FontSize="36" FontFamily="Calibri Light" Grid.Column="1" HorizontalAlignment="Stretch"/>
<TextBox Text="°C" TextWrapping="Wrap" IsEnabled="False" Margin="567,146,92,282" Style="{StaticResource Titoli}" Height="52" Width="38" FontSize="36" FontFamily="Calibri Light" Grid.Column="1" VerticalAlignment="Stretch"/>
<TextBox Text="°C" TextWrapping="Wrap" IsEnabled="False" Margin="285,313,374,115" Style="{StaticResource Titoli}" Height="52" Width="38" FontSize="36" FontFamily="Calibri Light" Grid.Column="1" VerticalAlignment="Stretch"/>
<TextBox Text="°C" TextWrapping="Wrap" IsEnabled="False" Margin="567,313,92,115" Style="{StaticResource Titoli}" Height="52" Width="38" FontSize="36" FontFamily="Calibri Light" Grid.Column="1" HorizontalAlignment="Stretch"/>
<!-- Sezione Numerazione Sonde -->
<TextBox Text="T1" TextWrapping="Wrap" IsEnabled="False" Margin="278,94,348,308" Style="{StaticResource Titoli}" FontSize="48" FontFamily="Calibri Light" Grid.Column="1" d:LayoutOverrides="LeftPosition, RightPosition, TopPosition, BottomPosition" VerticalAlignment="Stretch"/>
<TextBox Text="T2" TextWrapping="Wrap" IsEnabled="False" Margin="560,94,66,308" Style="{StaticResource Titoli}" FontSize="48" FontFamily="Calibri Light" Grid.Column="1" d:LayoutOverrides="TopPosition, BottomPosition" Width="71"/>
<TextBox Text="T3" TextWrapping="Wrap" IsEnabled="False" Margin="278,261,348,141" Style="{StaticResource Titoli}" FontSize="48" FontFamily="Calibri Light" Grid.Column="1" d:LayoutOverrides="LeftPosition, RightPosition, TopPosition, BottomPosition" HorizontalAlignment="Stretch"/>
<TextBox Text="T4" TextWrapping="Wrap" IsEnabled="False" Margin="560,261,66,141" Style="{StaticResource Titoli}" FontSize="48" FontFamily="Calibri Light" Grid.Column="1" d:LayoutOverrides="TopPosition, BottomPosition" VerticalAlignment="Stretch" Width="71"/>
<!-- Sezione Valori di Misura -->
---------------EDIT As suggested by @touseefbsb here is the version with TextBlock, but still, none is displayed in Debug...
<!-- Sezione Unità di Misura -->
<TextBlock Text="°C" TextWrapping="Wrap" IsTapEnabled="False" Margin="285,146,369,290" FontSize="36" FontFamily="Calibri Light" Grid.Column="1" d:LayoutOverrides="TopPosition, BottomPosition" Foreground="White" Width="43" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
<TextBlock Text="°C" TextWrapping="Wrap" IsTapEnabled="False" Margin="567,146,92,282" Height="52" Width="38" FontSize="36" FontFamily="Calibri Light" Grid.Column="1" VerticalAlignment="Stretch" Foreground="White"/>
<TextBlock Text="°C" TextWrapping="Wrap" IsTapEnabled="False" Margin="285,313,374,115" Height="52" Width="38" FontSize="36" FontFamily="Calibri Light" Grid.Column="1" VerticalAlignment="Stretch" Foreground="White"/>
<TextBlock Text="°C" TextWrapping="Wrap" IsTapEnabled="False" Margin="567,313,92,115" Height="52" Width="38" FontSize="36" FontFamily="Calibri Light" Grid.Column="1" HorizontalAlignment="Stretch" Foreground="White"/>
<!-- Sezione Numerazione Sonde -->
<TextBlock Text="T1" TextWrapping="Wrap" IsTapEnabled="False" Margin="277,94,357,335" FontSize="48" FontFamily="Calibri Light" Grid.Column="1" d:LayoutOverrides="LeftPosition, RightPosition, TopPosition, BottomPosition" FocusVisualPrimaryBrush="White" Foreground="White"/>
<TextBlock Text="T2" TextWrapping="Wrap" IsTapEnabled="False" Margin="560,94,66,343" FontSize="48" FontFamily="Calibri Light" Grid.Column="1" d:LayoutOverrides="TopPosition, BottomPosition" Width="71" FocusVisualPrimaryBrush="White" Foreground="White" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
<TextBlock Text="T3" TextWrapping="Wrap" IsTapEnabled="False" Margin="285,261,344,163" FontSize="48" FontFamily="Calibri Light" Grid.Column="1" d:LayoutOverrides="HorizontalAlignment, TopPosition, BottomPosition" FocusVisualPrimaryBrush="White" Foreground="White" Width="68" RenderTransformOrigin="0.397,0.913"/>
<TextBlock Text="T4" TextWrapping="Wrap" IsTapEnabled="False" Margin="560,261,66,175" FontSize="48" FontFamily="Calibri Light" Grid.Column="1" d:LayoutOverrides="TopPosition, BottomPosition" Width="71" FocusVisualPrimaryBrush="White" Foreground="White" VerticalAlignment="Stretch"/>
<!-- Sezione Valori di Misura -->