سلام بر تمامی برنامه نویسان عزیز 😉 در این پست آموزش تنظیم Margin با کدنویسی و استفاده از کلاس Thickness در #C را آماده کردم. امیدوارم که این کد برای شما مفید باشد.
تصاویر خروجی نهایی این کد:
کد تنظیم Margin با کدنویسی و استفاده از کلاس Thickness در #C :
<StackPanel Name="root"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfApplication1.FEMarginProgrammatic">
<StackPanel.Resources>
<Style TargetType="Button">
<Setter Property="Height" Value="25"/>
<Setter Property="Width" Value="250"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="FontSize" Value="20"/>
</Style>
</StackPanel.Resources>
<Button Click="OnClick" Margin="10" Name="btn1">Click To See Change!!</Button>
</StackPanel>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace WpfApplication1
{
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfApplication1.FEMarginProgrammatic">
<StackPanel.Resources>
<Style TargetType="Button">
<Setter Property="Height" Value="25"/>
<Setter Property="Width" Value="250"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="FontSize" Value="20"/>
</Style>
</StackPanel.Resources>
<Button Click="OnClick" Margin="10" Name="btn1">Click To See Change!!</Button>
</StackPanel>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace WpfApplication1
{