I Want to Change Color of Shapes Background.
So, I tried change backgound of SelectedItem(SelectedShape) in ViewModel. then, Not changed.
I checked SelectedShape background property.
It changed.
but Not in the View.
And I tried using behind-code. but I failed.
there's My Code.
1.XAML
<telerik:RadDiagram x:Name="diagram" GraphSource="{Binding GraphSource}" SelectedItem="{Binding SelectedShape, Mode=TwoWay}"
<telerik:RadDiagram.ShapeStyle>
<Style TargetType="telerik:RadDiagramShape">
<Setter Property="Position" Value="{Binding Position, Mode=TwoWay}"/>
<Setter Property="Geometry" Value="{Binding Geometry, Mode=TwoWay}"/>
<Setter Property="Background" Value="{Binding Background, Mode=TwoWay}"/>
</Style>
</telerik:RadDiagram.ShapeStyle>
<telerik:RadButton Width="100" Height="30" Content="ChangeColor" Command="{Binding ColorCommand}"/>
2. ViewModel
private void ChageBrush(object param)
{
selectedShape.Background = new BrushConverter().ConvertFromString(SelectedBrushColor) as SolidColorBrush;
}
thanks.
This setup seems correct. The only thing that I've noticed is that the ChangeBrush method is setting a field named selectedShape. From the SelectedItem's binding it looks like there is also a corresponding property called SelectedShape. In order to reflect the change in the UI, you will probably need to set the property SelectedShape, instead of the field selectedShape. And also to raise the PropertyChanged event.
I've attached a small example showing this approach. I hope it helps.