作者:Binggo89 | 来源:互联网 | 2023-05-19 05:04
IhaveaSurfaceRadioButtonthathastochangetheVisibilityofScatterView(scatterViewCoordinates
I have a SurfaceRadioButton that has to change the Visibility of ScatterView (scatterViewCoordinates)
我有一个SurfaceRadioButton,它必须改变ScatterView的可见性(scatterViewCoordinates)
First, what I have done was to change the Visibility of the object ()
首先,我所做的是改变对象的可见性()
private void CoordinatesChecked(object sender, RoutedEventArgs e)
{
scatterViewCoordinates.Visibility = Visibility.Visible;
}
After that I modified the XAML code, and I included the name of the ScatterView in the Tag value of the SurfaceRadioButton.
之后我修改了XAML代码,并在SurfaceRadioButton的Tag值中包含了ScatterView的名称。
Now I was trying to cast the Tag value contained in the SurfaceRadioButton to a ScatterView, and after that to call the Visibility method.
现在我试图将SurfaceRadioButton中包含的Tag值转换为ScatterView,然后调用Visibility方法。
private void CoordinatesChecked(object sender, RoutedEventArgs e)
{
string senderName = ((SurfaceRadioButton)sender).Tag.ToString();
((ScatterView)senderName).Visibility = Visibility.Hidden;
}
And I get this error
我得到了这个错误
Cannot cast expression of type 'string' to type 'ScatterView'
无法将'string'类型的表达式转换为'ScatterView'类型
Any ideas to resolve this problem (I don't even now if this respect the MVVM concept :s) ?
任何解决这个问题的想法(如果这尊重MVVM概念,我现在甚至都没有)?
Suggestions are welcomed too.
建议也受到欢迎。
2 个解决方案