@@ -315,7 +315,7 @@ The [IconTemplate](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Tools.C
315
315
mc:Ignorable="d"
316
316
Title="MainWindow" Height="450" Width="800">
317
317
<Window.DataContext>
318
- <local:Model />
318
+ <local:ViewModel />
319
319
</Window.DataContext>
320
320
<Window.Resources>
321
321
<DataTemplate x:Key="checkedIcon">
@@ -344,12 +344,12 @@ The [IconTemplate](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Tools.C
344
344
Stretch="Fill" />
345
345
</Grid>
346
346
</DataTemplate>
347
- <local:IconTemplateSelector x:Key="IconTemp " CheckedIcon="{StaticResource checkedIcon}" UnCheckedIcon="{StaticResource unCheckedIcon}"/>
347
+ <local:IconTemplateSelector x:Key="IconTemplateSelector " CheckedIcon="{StaticResource checkedIcon}" UnCheckedIcon="{StaticResource unCheckedIcon}"/>
348
348
</Window.Resources>
349
349
<Grid>
350
350
<StackPanel VerticalAlignment="Center">
351
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}"/>
352
+ <syncfusion:ButtonAdv x:Name="button" HorizontalAlignment="Center" Margin="10" Label="IconTemplateSelector" IconTemplateSelector="{StaticResource IconTemplateSelector }" DataContext="{Binding IsChecked}"/>
353
353
</StackPanel>
354
354
</Grid>
355
355
</Window >
@@ -361,9 +361,8 @@ The [IconTemplate](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Tools.C
361
361
public class ViewModel : INotifyPropertyChanged
362
362
{
363
363
private bool _isChecked;
364
- public event PropertyChangedEventHandler PropertyChanged;
365
364
public bool IsChecked
366
- {
365
+ {
367
366
get { return _isChecked; }
368
367
set
369
368
{
@@ -375,6 +374,8 @@ The [IconTemplate](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Tools.C
375
374
}
376
375
}
377
376
377
+
378
+ public event PropertyChangedEventHandler PropertyChanged;
378
379
protected void OnPropertyChanged(string propertyName) =>
379
380
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
380
381
}
@@ -384,23 +385,20 @@ The [IconTemplate](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Tools.C
384
385
public DataTemplate CheckedIcon { get; set; }
385
386
public DataTemplate UnCheckedIcon { get; set; }
386
387
public override DataTemplate SelectTemplate(object item, DependencyObject container)
387
- {
388
+ {
388
389
if (item is bool isChecked)
389
390
{
390
391
return isChecked ? CheckedIcon : UnCheckedIcon;
391
392
}
392
393
return base.SelectTemplate(item, container);
393
- }
394
+ }
394
395
}
395
396
396
397
{% endhighlight %}
397
398
398
399
{% endtabs %}
399
400
400
- ![ Setting Image] ( Getting-Started_images/Getting-Started_img13.png )
401
-
402
- ![ Setting Image] ( Getting-Started_images/Getting-Started_img14.png )
403
-
401
+ ![ IconTemplateSelector in WPF Button] ( Getting-Started_images/Getting-Started_IconTemplateSelector.gif )
404
402
405
403
N> The [ ButtonAdv] ( https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Tools.Controls.ButtonAdv.html ) loads the icon in the following priority order.
406
404
* [ IconTemplateSelector] ( https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Tools.Controls.ButtonAdv.html#Syncfusion_Windows_Tools_Controls_ButtonAdv_IconTemplateSelector )
0 commit comments