سلام بر برنامه نویسان عزیز 😉 در این مطلب آموزش تنظیم دکمه پیشفرض با IsDefault=True با wpf و سی شارپ #C را آماده کردم. امیدوارم که این کد برای شما مفید باشد.
خروجی این کد:
کد تنظیم دکمه پیشفرض با IsDefault=True با wpf و سی شارپ #C :
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF" Height="100" Width="300">
<DockPanel>
<TextBox DockPanel.Dock="Top" Margin="5">Button three is the default button.</TextBox>
<StackPanel HorizontalAlignment="Center" DockPanel.Dock="Bottom" Orientation="Horizontal">
<Button Click="SharedButtonClickHandler" Content="Button One" Name="btnOne" Width="75" />
<Button Click="SharedButtonClickHandler" Content="Button Two" Name="btnTwo" Width="75" />
<Button Click="SharedButtonClickHandler" Content="Button Three" IsDefault="True" Margin="5" Name="btnThree" />
</StackPanel>
</DockPanel>
</Window>
//File:Window.xaml.cs
using System.Windows;
using System.Windows.Controls;
namespace WpfApplication1
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF" Height="100" Width="300">
<DockPanel>
<TextBox DockPanel.Dock="Top" Margin="5">Button three is the default button.</TextBox>
<StackPanel HorizontalAlignment="Center" DockPanel.Dock="Bottom" Orientation="Horizontal">
<Button Click="SharedButtonClickHandler" Content="Button One" Name="btnOne" Width="75" />
<Button Click="SharedButtonClickHandler" Content="Button Two" Name="btnTwo" Width="75" />
<Button Click="SharedButtonClickHandler" Content="Button Three" IsDefault="True" Margin="5" Name="btnThree" />
</StackPanel>
</DockPanel>
</Window>
//File:Window.xaml.cs
using System.Windows;
using System.Windows.Controls;
namespace WpfApplication1
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();