C
C#2y ago
JJ

❔ wpf : I don't want blind contents like buttons textbox when I window size is change

I want the text box inside the panel to be automatically adjusted according to the size of the window, and the button to remain the same size and not be covered by the window. In conclusion, I don't want buttons and textboxes to be covered by windows. <Window x:Class="StickyNotes.App.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:StickyNotes.App" mc:Ignorable="d" WindowStyle="ThreeDBorderWindow"
Title="MainWindow" Height="600" Width="500" > <StackPanel Orientation="Vertical"> <StackPanel Name="st" Orientation="Horizontal"> <TextBox Width="320"></TextBox> <Button>Btn1</Button> </StackPanel>
</StackPanel>
</Window>
8 Replies
JJ
JJOP2y ago
the result i want finally You can see red part. When Window size is small, Contents isn't blind
Buddy
Buddy2y ago
Are you using the designer? Don't You set the size of the textbox to a fixed number, that will not scale
JJ
JJOP2y ago
I didn't use blenzer ? Im just exercise wpf (with xaml)
Buddy
Buddy2y ago
Leave Width and Height empty if you want them to scale $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
JJ
JJOP2y ago
Umm.. Im just don't want make blind button by window when I resize window
Buddy
Buddy2y ago
You can use DockPanel control You can dock the textbox to the left, and the button to the right. Note that textbox has to be the last element because only the last element is filled to the remaining space
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.
Want results from more Discord servers?
Add your server