C# 如何更改windows Phone 8中选定的单选按钮?
我正在尝试在我的wp8应用程序中实现本地化。 我有两个单选按钮(阿拉伯语和英语)当用户选择其中一个单选按钮时,弹出窗口显示他是否确定要更改应用程序的语言如果他选择“确定”,则应用程序的语言会更改,但如果他选择“取消”,则语言不会更改,但问题是即使用户按下“取消”,单选按钮也会切换 如何阻止切换发生 这是我的Xaml代码,如果选中任何单选按钮,该代码将被绑定C# 如何更改windows Phone 8中选定的单选按钮?,c#,windows-phone-8,radio-button,C#,Windows Phone 8,Radio Button,我正在尝试在我的wp8应用程序中实现本地化。 我有两个单选按钮(阿拉伯语和英语)当用户选择其中一个单选按钮时,弹出窗口显示他是否确定要更改应用程序的语言如果他选择“确定”,则应用程序的语言会更改,但如果他选择“取消”,则语言不会更改,但问题是即使用户按下“取消”,单选按钮也会切换 如何阻止切换发生 这是我的Xaml代码,如果选中任何单选按钮,该代码将被绑定 <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20">
<RadioButton Content="English" Foreground="Black" FontSize="30" IsChecked="{Binding isenglishchecked,Mode=TwoWay, Source={StaticResource appSettings}}" Checked="RadioButton_Checked"/>
<RadioButton Content="Arabic" Foreground="Black" FontSize="30" IsChecked="{Binding isarabicchecked,Mode=TwoWay, Source={StaticResource appSettings}}" Checked="RadioButton_Checked"/>
</StackPanel>
</Grid>
public bool isenglishchecked
{
get
{
return GetValueOrDefault<bool>(isenglishcheckedname, isenglishcheckedDefault);
}
set
{
var result = MessageBox.Show("This Will Change the Language of the App Do you Want to continue ?", "Language Change", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
if (AddOrUpdateValue(isenglishcheckedname, value))
{
Save();
if (isenglishchecked)
{
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
MainViewModel.stationnamelist = null;
Messenger.Default.Send<string>("mainpage", "tomainpage");
(Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
}
else
{
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("ar-AE");
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ar-AE");
MainViewModel.stationnamelist = null;
Messenger.Default.Send<string>("mainpage", "tomainpage");
(Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
}
}
}
else
{
(Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/Skins/SelectLanguage.xaml", UriKind.Relative));
}
}
}
public bool isarabicchecked
{
get
{
return GetValueOrDefault<bool>(isarabiccheckedname, isarabiccheckedDefault);
}
set
{
if (AddOrUpdateValue(isarabiccheckedname, value))
{
Save();
}
}
}
公共图书馆正在检查中
{
得到
{
返回GetValuerDefault(isenglishcheckedname,isenglishcheckedDefault);
}
设置
{
var result=MessageBox.Show(“这将更改应用程序的语言是否要继续?”,“语言更改”,MessageBoxButton.ok取消);
if(result==MessageBoxResult.OK)
{
if(AddOrUpdateValue(isenglishcheckedname,值))
{
Save();
如果(已选中)
{
Thread.CurrentThread.CurrentCulture=新系统.Globalization.CultureInfo(“en-US”);
Thread.CurrentThread.CurrentUICulture=新系统.Globalization.CultureInfo(“en-US”);
MainViewModel.stationnamelist=null;
senger.Default.Send(“主页”、“tomainpage”);
(Application.Current.RootVisual作为PhoneApplicationFrame)导航(新Uri(“/MainPage.xaml”,UriKind.Relative));
}
其他的
{
Thread.CurrentThread.CurrentCulture=新系统.Globalization.CultureInfo(“ar AE”);
Thread.CurrentThread.CurrentUICulture=新系统.Globalization.CultureInfo(“ar AE”);
MainViewModel.stationnamelist=null;
senger.Default.Send(“主页”、“tomainpage”);
(Application.Current.RootVisual作为PhoneApplicationFrame)导航(新Uri(“/MainPage.xaml”,UriKind.Relative));
}
}
}
其他的
{
导航(新Uri(“/Skins/SelectLanguage.xaml”,UriKind.Relative));
}
}
}
公共图书馆
{
得到
{
返回GetValuerDefault(isarabiccheckedname,isarabiccheckedDefault);
}
设置
{
if(AddOrUpdateValue(isarabiccheckedname,值))
{
Save();
}
}
}
可能发生的情况是,UI层(Silverlight)响应用户的点击,愉快地更改自己的状态,然后设置isenglishchecked或isarabicchecked的值。属性的值没有改变这一事实并不重要——Silverlight没有注意到。(不更改属性值以响应set调用是非标准行为,因此Silverlight会像这样“行为不当”也就不足为奇了)
您可以尝试以下几点:
谢谢你的回复,迈克,但我昨天才解决了这个问题。。。顺便说一下,谢谢