我有一点问题,我有一个翻译JSON变量.我想把它放在HTML上.有办法以某种方式制作它吗?
我的JS档案:
var Karting = Karting || {};
Karting = {
lang : 'lv',
translationsLV: {
"Home" : "Zi?as",
},
}
Run Code Online (Sandbox Code Playgroud)
我想这样做:
我的页面是静态的,我没有使用任何模板引擎.
<li><a class="active" href="#">Karting.translationsLV['Home']</a></li>
Run Code Online (Sandbox Code Playgroud)
编辑:
补充一下:
$(window).load( function() {
var translations;
if (Karting.lang=='lv')
{
translations = Karting.translationsLV;
}
else
{
translations = Karting.translationsENG;
}
}, false );
Run Code Online (Sandbox Code Playgroud)
这不显示我的元素
document.write(translations['Home'])
Run Code Online (Sandbox Code Playgroud)
UncaughtRefferenceError - 未定义翻译
我有一个在运行时更改 UI 的应用程序。这是我更改语言的代码:
public void SwitchLanguage(SupportedLanguage language)
{
// Check if passed argument is different from current language
if (CurrentLanguage != language.Type)
{
// Set the new current language
CurrentLanguage = language.Type;
// Override tha application primary language ( it will automatically save the language preference )
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = language.FourDigitCode;
ResourceContext.GetForViewIndependentUse().Reset();
ResourceContext.GetForCurrentView();
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocalizedResourceMap"));
// Notify code about the changes
this.LanguageChanged?.Invoke(this, new EventArgs());
}
}
Run Code Online (Sandbox Code Playgroud)
所有本地化工作都很好,除了 CalendarDatePicker - 它的 Flyout 没有本地化(在运行时,当我重新启动应用程序时 - 一切都很好)。
以下是示例
打开一个页面并选择CalendarDatePicker:
将语言切换为俄语:
我尝试这样做:
// Attach …Run Code Online (Sandbox Code Playgroud) 主网格有下一个XAML:
<ListView Grid.Row="1" x:Name="NewsListBox">
<ListView.Background>
<SolidColorBrush Color="#FF006C67" Opacity="0.5"/>
</ListView.Background>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Vertical"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
Run Code Online (Sandbox Code Playgroud)
它看起来不错,它是如何需要的:
但它不会滚动内容!

好的,我添加了ScrollViewer:
<ScrollViewer Grid.Row="1" VerticalScrollMode="Disabled" ZoomMode="Disabled">
<ListView Grid.Row="1" x:Name="NewsListBox">
<ListView.Background>
<SolidColorBrush Color="#FF006C67" Opacity="0.5"/>
</ListView.Background>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Vertical"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
</ScrollViewer>
Run Code Online (Sandbox Code Playgroud)
并且它垂直堆叠所有内容:

我究竟做错了什么?
我需要帮助:
我们的后端由自签名证书保护.让我们称之为:OurMegaCoolCertificate.cer
因此,我们使用certmgr.msc将此证书导入我们的开发人员计算机.现在我们可以使用以下代码从后端检索数据:
async public static Task<string> getData(string Id, string Type)
{
String url = "https://BACKEND/API/?Id=" + Id + "&Type=" + Type;
HttpClientHandler aHandler = new HttpClientHandler();
aHandler.ClientCertificateOptions = ClientCertificateOption.Automatic;
HttpClient aClient = new HttpClient(aHandler);
aClient.DefaultRequestHeaders.ExpectContinue = false;
aClient.DefaultRequestHeaders.MaxForwards = 3;
Uri requestUri = new Uri(url);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
//request.Headers.ExpectContinue = false;
var result = await aClient.GetAsync(requestUri, HttpCompletionOption.ResponseContentRead);
var responseHeader = result.Headers;
//Debug.WriteLine(responseHeader.WwwAuthenticate);
var responseBody = await result.Content.ReadAsStringAsync();
return responseBody;
}
Run Code Online (Sandbox Code Playgroud)
但是当然我们不能告诉用户我们的应用程序,手动安装证书,有没有办法将这个证书添加到项目并使用它?或者导入到用户机程序?请指导我,我是SSL安全新手
我已设法做到这一点,没有错误,但请求失败,看起来像请求找不到证书:
private …Run Code Online (Sandbox Code Playgroud) 这是一个非常简单的任务,但不知怎的,它失败了......
private void TextBlock_Tap_1(object sender, System.Windows.Input.GestureEventArgs e)
{
if (WasSwipe != true)
{
//JUST TO CHECK THAT CODE GETS HERE - RUNS PERFECT
MessageBox.Show("");
//FUNCTION
var phoneCallTask = new PhoneCallTask
{
DisplayName = "Kunal Chowdhury",
PhoneNumber = "0208795446322"
};
phoneCallTask.Show();
//FAILS HERE, AFTER SHOW
}
else
{
WasSwipe = false;
}
}
Run Code Online (Sandbox Code Playgroud)
当我想显示任务时,它失败了:
消息:访问被拒绝.(HRESULT异常:0x80070005(E_ACCESSDENIED))
资料来源: Microsoft.Phone
堆栈跟踪: 在Microsoft.Phone.Tasks.PhoneCallTask.NativeMethods.PhoneInitiateOutgoingPhoneCall_External(String pDialString,String pDisplayName)
在Microsoft.Phone.Tasks.PhoneCallTask.PhoneDial(Object phoneCallTask)
在System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(对象状态)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean preserveSyncCtx)
在System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
在System.Threading.ThreadPoolWorkQueue.Dispatch()
在System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
此外: …
windows-phone-7 windows-phone windows-phone-7.1 windows-phone-8
你好,我有一个下一个对象:
public class Industry
{
public int? id { get; set; }
public int? parentId { get; set; }
public string name { get; set; }
public List<Industry> industryList { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
因此它用于创建分层对象,它可以具有任何级别计数.
我需要创建一个函数,在这个树中找到一个给定id的对象.
到目前为止我写过这个:
//IndustryList - is a fully created hirerchical object, the Root List of industries
//id - is a id of industry that i wish to find.
private Industry GetIndustryById(List<Industry> IndustryList, int? id)
{
if (id != null)
{
foreach (Industry industry in IndustryList)
{ …Run Code Online (Sandbox Code Playgroud) 你好,我有另一个问题/疑问.我有一个自定义控件,上面有一个按钮:

我想删除它中的图像,所以我从属性检查器 - >图像中删除了引用,所以现在我在设计器中的按钮看起来像这样:

但是当我在模拟器上启动它时,当我按下按钮(只需按下按钮,而不是点击)时,图像就会显示出来!它从何而来?项目文件中是否有任何按钮状态样式,可以写入?
因为按钮有两个引用 - 1个插座和1个动作,并且没有一个用于向按钮添加图像!我只是不明白从图像到哪里...
我需要检查我的双号是否可以在没有余数的情况下分成0.05.所以我这样做:
if (!double.TryParse(ProductPriceTextBox.Text, out price) || !(0 < price) || !(price%0.05==0.0))
Run Code Online (Sandbox Code Playgroud)
问题是我的ProductPrice可以包含0.05,0.1,0.2,0.5,1,2欧元的硬币.
因此,所有产品价格必须是:price%0.05==0,即:
1欧元,1.5欧元,0.5欧元 - 通过1.21欧元,0.01欧元 - 失败.
但编译器提示我:
(price%0.05==0.0)
Run Code Online (Sandbox Code Playgroud)
浮点数与等式算子的比较.可能失去预决定
无法弄清楚它失败的原因......
我当然可以这样做:
int priceInCents= price*100;
(priceInCents%5==0)
Run Code Online (Sandbox Code Playgroud)
但我认为还有另一种方式.
c# ×3
.net ×1
calendarview ×1
dom ×1
html ×1
ios ×1
ipad ×1
javascript ×1
listview ×1
objective-c ×1
recursion ×1
ssl ×1
tree ×1
uibutton ×1
uwp ×1
uwp-xaml ×1
windows ×1
windows-8 ×1
windows-8.1 ×1
xaml ×1