我正在尝试在我的 wp8 应用程序中实现本地化。当用户选择其中一个单选按钮时,我有两个单选按钮(阿拉伯语和英语),然后出现弹出窗口,如果他选择确定他想更改应用程序的语言,那么应用程序的语言会改变,但如果他选择取消,那么语言不会发生变化,但问题是即使用户按下取消,单选按钮也会切换。
如何阻止切换发生?
这是我的 Xaml 代码和如果选中任何单选按钮则绑定的代码..
<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();
}
}
}