❔ ✅ Textbox is way bigger than it is in designer C# / UWP / Blank App Template

Everything looks great in the designer but when you run it, you have to full screen it otherwise only the OK button will show, and when you do full screen it, the text box is way bigger than it should be. I'll attach a copy of the XAMAL code, thanks!
13 Replies
TypicalSoldier
TypicalSoldierOP2y ago
<Page x:Class="Hello.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Hello" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid RowSpacing="2" ColumnSpacing="2"> <TextBlock TextWrapping="Wrap" Text="Please enter your name" Margin="531,32,703,926" Height="NaN" Width="NaN" FontSize="24"/> <TextBox x:Name="userName" TextWrapping="Wrap" Text="TextBox" Margin="531,85,845,864" Height="NaN" Width="NaN" FontSize="24"/> <Button x:Name="OK" Content="OK" Margin="808,91,0,0" VerticalAlignment="Top" FontSize="24"/> </Grid> </Page>
Buddy
Buddy2y ago
This is why Margin $rulesofwpf
MODiX
MODiX2y ago
Rules of WPF:

❌ Avoid the WPF Designer to eliminate a category of confusing bugs
❌ Don't rely on Margin as the primary tool for layouts
❌ Avoid writing UserControls or subclassing to extend a default control -- use Behaviors instead (Microsoft.Xaml.Behaviors.Wpf)

✅ Write XAML by hand and autoformat with "Ctrl K,D" or XAML Styler
✅ Rely upon XAML Hot Reload to design your app's UI at runtime
✅ Use layout controls (Grid, DockPanel, etc) to support proper resizing
✅ Use data binding to eliminate glue code and state synchronization issues
✅ Use collection controls and DataTemplate to dynamically create lists of controls
✅ Learn MVVM to create maintainable apps
✅ Use the Dispatcher to update controls from non-UI threads
✅ WPF's default controls can be easily modernized via $wpfuilibs
✅ Include relevant XAML, code-behind, and ViewModel code for questions when possible
Rules of WPF:

❌ Avoid the WPF Designer to eliminate a category of confusing bugs
❌ Don't rely on Margin as the primary tool for layouts
❌ Avoid writing UserControls or subclassing to extend a default control -- use Behaviors instead (Microsoft.Xaml.Behaviors.Wpf)

✅ Write XAML by hand and autoformat with "Ctrl K,D" or XAML Styler
✅ Rely upon XAML Hot Reload to design your app's UI at runtime
✅ Use layout controls (Grid, DockPanel, etc) to support proper resizing
✅ Use data binding to eliminate glue code and state synchronization issues
✅ Use collection controls and DataTemplate to dynamically create lists of controls
✅ Learn MVVM to create maintainable apps
✅ Use the Dispatcher to update controls from non-UI threads
✅ WPF's default controls can be easily modernized via $wpfuilibs
✅ Include relevant XAML, code-behind, and ViewModel code for questions when possible
Buddy
Buddy2y ago
❌ Avoid the WPF Designer to eliminate a category of confusing bugs ❌ Don't rely on Margin as the primary tool for layouts
Use layout controls
TypicalSoldier
TypicalSoldierOP2y ago
thanks...textbook im reading for class instructs me to...lol
Buddy
Buddy2y ago
😂 You should get a refund for that book
ero
ero2y ago
no shot someone was that confident enough in doing something so wrong that they decided to write a whole book about being wrong that's insane
TypicalSoldier
TypicalSoldierOP2y ago
get this...it's for VS pepewhy there a command that says how to use layout controls?
TypicalSoldier
TypicalSoldierOP2y ago
okay, i'll give it a shot i can't believe i'm doing this shit...thanks guys
Buddy
Buddy2y ago
No clue why Microsoft decided the idea to use Margin for the designer was a good idea.
TypicalSoldier
TypicalSoldierOP2y ago
Thanks again!
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity. Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server