I want to bind my MultiDataTrigger.Conditions to radio button, but it's not working. here is my scenario.
In wpf, I have a GridPanel, which suppose to have radiobuttons in it.
I generate dynamic radiobuttons into GridPanel, like this:
RadioButton allAccountBtn = new RadioButton();
allAccountBtn.Name = "allAccountBtn";
GridPanel.Children.Add(allAccountBtn);
then in my xaml, I had an image button which will change based in this radiobutton selection, and another control's property.
here is my code:
<Button>
<Button.Template>
<ControlTemplate>
<Image Name="addFolderIcon" Source="Icon/Decoration/folderColor.png">
<ControlTemplate.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Tag, ElementName=folderBackBtn}" Value="{x:Null}"/>
<Condition Binding="{Binding IsChecked, ElementName=allAccountsBtn}" Value="True"/>
</MultiDataTrigger.Conditions>
<Setter Property="Control.IsEnabled" Value="False"/>
<Setter TargetName="addFolderIcon" Property="Source" Value="Icon/Decoration/folder.png"/>
</MultiDataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
When I run the program, it display error code:"Cannot find source for binding with reference", and the conditions return false for second condition(elementName=allAccountsBtn)
Why is this happen?
Any way can I refer to get IsChecked property from dynamically named and generated RadioButton?