Я хочу передать содержимое переключателя между страницами. XAML Код:Пропустить содержимое переключателя между страницами
<RadioButton Name="errorCorrectionHLevelRadioButton"
Content="H (~30% correction)"
GroupName="errorCorrectionLevel"
IsChecked="True" BorderBrush="Black" Foreground="Black" Background="Black"
/>
<RadioButton Name="errorCorrectionLLevelRadioButton"
Content="Q (~25% correction)"
GroupName="errorCorrectionLevel" BorderBrush="Black" Foreground="Black" Background="Black"
/>
<RadioButton Name="errorCorrectionMLevelRadioButton"
Content="M (~15% correction)"
GroupName="errorCorrectionLevel" BorderBrush="Black" Foreground="Black" Background="Black"
/>
<RadioButton Name="errorCorrectionQLevelRadioButton"
Content="L (~7% correction)"
GroupName="errorCorrectionLevel" BorderBrush="Black" Foreground="Black" Background="Black"
/>
Первый код страницы:
string myECL;
if (errorCorrectionHLevelRadioButton.IsChecked == true)
myECL = ErrorCorrectionLevel.H.ToString();
else if (errorCorrectionQLevelRadioButton.IsChecked == true)
myECL = ErrorCorrectionLevel.Q.ToString();
else if (errorCorrectionMLevelRadioButton.IsChecked == true)
myECL = ErrorCorrectionLevel.M.ToString();
else
myECL = ErrorCorrectionLevel.L.ToString();
NavigationService.Navigate(new Uri("/QRGeneratePage.xaml?text=" + textToEncodeTextBox.Text +"&errorCorrection="+myECL+"&logo="+logoQrCodeImage.Source, UriKind.Relative));
А на второй странице я хочу использовать дату формы радио бутон. Например: У меня есть конструктор, где:
string errorCorrectionLevelChoose = String.Empty;
if (NavigationContext.QueryString.TryGetValue("errorCorrection", out errorCorrectionLevelChoose))
{
ErrorCorrectionLevel ecl = (ZXing.QrCode.Internal.ErrorCorrectionLevel)errorCorrectionLevelChoose;
}
var writer = new BarcodeWriter
{
Format = BarcodeFormat.QR_CODE,
Renderer = new ZXing.Rendering.WriteableBitmapRenderer()
{
Foreground = colorQRCode
},
Options = new ZXing.QrCode.QrCodeEncodingOptions
{
Height = 300,
Width = 300,
Margin = 1,
ErrorCorrection = ErrorCorrectionLevel.H
}
};
В этой строке ErrorCorrection = ErrorCorrectionLevel.H я хочу использовать мои данные из радио-кнопки. Так что если пользователь может выбрать
<RadioButton Name="errorCorrectionLLevelRadioButton"
Content="Q (~25% correction)"
GroupName="errorCorrectionLevel" BorderBrush="Black" Foreground="Black" Background="Black"
/>
На второй странице будет:
ErrorCorrection = ErrorCorrectionLevel.Q
Вы знаете, как я могу это сделать?
ErrorCorrectionLevel.H это класс ZXing.QrCode.Internal.ErrorCorrectionLevel, поэтому это не моя переменная. После ErrorCorrectionLevel. У меня есть выбор из четырех вариантов (Q, M, H, L). – user2962457
@ user2962457 Вы можете играть со строками, которые вы переходите на следующую страницу, а затем в зависимости от какой строки вы можете выбрать CorrectionLevel. Или вы можете использовать этот ErrorCorrection как сложный объект - я отредактировал сообщение выше. Я думаю, вы должны выяснить, как это сделать. – Romasz
Можете ли вы посмотреть мой первый пост? Я редактировал и имел ошибку; – user2962457