Skip to content

Commit 7a1584c

Browse files
authored
Update Getting-Started.md
1 parent e512349 commit 7a1584c

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

wpf/Button/Getting-Started.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,11 @@ The [IconTemplate](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Tools.C
314314
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
315315
mc:Ignorable="d"
316316
Title="MainWindow" Height="450" Width="800">
317+
317318
<Window.DataContext>
318-
<local:Model/>
319+
<local:ViewModel/>
319320
</Window.DataContext>
321+
320322
<Window.Resources>
321323
<DataTemplate x:Key="checkedIcon">
322324
<Grid Width="12" Height="16">
@@ -344,12 +346,13 @@ The [IconTemplate](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Tools.C
344346
Stretch="Fill" />
345347
</Grid>
346348
</DataTemplate>
347-
<local:IconTemplateSelector x:Key="IconTemp" CheckedIcon="{StaticResource checkedIcon}" UnCheckedIcon="{StaticResource unCheckedIcon}"/>
349+
<local:IconTemplateSelector x:Key="IconTemplateSelector" CheckedIcon="{StaticResource checkedIcon}" UnCheckedIcon="{StaticResource unCheckedIcon}"/>
348350
</Window.Resources>
351+
349352
<Grid>
350353
<StackPanel VerticalAlignment="Center">
351-
<CheckBox Name="Check" IsChecked="{Binding IsChecked,Mode=TwoWay}" HorizontalAlignment="Center" Content="ChangeIcon"/>
352-
<syncfusion:ButtonAdv x:Name="button" HorizontalAlignment="Center" Margin="10" Label="IconTemplateSelector" IconTemplateSelector="{StaticResource IconTemp}" DataContext="{Binding IsChecked}"/>
354+
<CheckBox Name="Check" IsChecked="{Binding IsChecked, Mode=TwoWay}" HorizontalAlignment="Center" Content="ChangeIcon"/>
355+
<syncfusion:ButtonAdv x:Name="button" HorizontalAlignment="Center" Margin="10" Label="IconTemplateSelector" IconTemplateSelector="{StaticResource IconTemplateSelector}" DataContext="{Binding IsChecked}"/>
353356
</StackPanel>
354357
</Grid>
355358
</Window>
@@ -361,9 +364,8 @@ The [IconTemplate](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Tools.C
361364
public class ViewModel : INotifyPropertyChanged
362365
{
363366
private bool _isChecked;
364-
public event PropertyChangedEventHandler PropertyChanged;
365367
public bool IsChecked
366-
{
368+
{
367369
get { return _isChecked; }
368370
set
369371
{
@@ -374,6 +376,8 @@ The [IconTemplate](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Tools.C
374376
}
375377
}
376378
}
379+
380+
public event PropertyChangedEventHandler PropertyChanged;
377381
378382
protected void OnPropertyChanged(string propertyName) =>
379383
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
@@ -383,24 +387,24 @@ The [IconTemplate](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Tools.C
383387
{
384388
public DataTemplate CheckedIcon { get; set; }
385389
public DataTemplate UnCheckedIcon { get; set; }
390+
386391
public override DataTemplate SelectTemplate(object item, DependencyObject container)
387-
{
392+
{
388393
if (item is bool isChecked)
389394
{
390395
return isChecked ? CheckedIcon : UnCheckedIcon;
391396
}
392397
return base.SelectTemplate(item, container);
393-
}
398+
}
394399
}
395400

396401
{% endhighlight %}
397402

398403
{% endtabs %}
399404

400-
![Setting Image](Getting-Started_images/Getting-Started_img13.png)
401-
402-
![Setting Image](Getting-Started_images/Getting-Started_img14.png)
405+
![IconTemplateSelector in WPF Button](Getting-Started_images/Getting-Started_img13.png)
403406

407+
![IconTemplateSelector in WPF Button](Getting-Started_images/Getting-Started_img14.png)
404408

405409
N> The [ButtonAdv](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Tools.Controls.ButtonAdv.html) loads the icon in the following priority order.
406410
* [IconTemplateSelector](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Tools.Controls.ButtonAdv.html#Syncfusion_Windows_Tools_Controls_ButtonAdv_IconTemplateSelector)

0 commit comments

Comments
 (0)