小编Che*_*ese的帖子

如何将变量插入HTML

我有一点问题,我有一个翻译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 - 未定义翻译

html javascript dom

5
推荐指数
1
解决办法
4万
查看次数

UWP 在运行时更改 CalendarDatePicker 语言

我有一个在运行时更改 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)

calendarview uwp uwp-xaml

5
推荐指数
1
解决办法
823
查看次数

WrapGrid水平滚动Windows 8

主网格有下一个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)

并且它垂直堆叠所有内容:

例

我究竟做错了什么?

xaml listview horizontal-scrolling windows-runtime

4
推荐指数
1
解决办法
2532
查看次数

在Windows 8应用程序中使用SSL证书编程

我需要帮助:

我们的后端由自签名证书保护.让我们称之为: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)

c# ssl windows-8 windows-runtime windows-8.1

4
推荐指数
1
解决办法
3083
查看次数

PhoneCallTask​​失败

这是一个非常简单的任务,但不知怎的,它失败了......

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

0
推荐指数
1
解决办法
334
查看次数

在对象树中查找对象

你好,我有一个下一个对象:

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)

c# windows tree recursion

0
推荐指数
1
解决办法
66
查看次数

处理按钮状态

你好,我有另一个问题/疑问.我有一个自定义控件,上面有一个按钮:

在此输入图像描述

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

在此输入图像描述

但是当我在模拟器上启动它时,当我按下按钮(只需按下按钮,而不是点击)时,图像就会显示出来!它从何而来?项目文件中是否有任何按钮状态样式,可以写入?

因为按钮有两个引用 - 1个插座和1个动作,并且没有一个用于向按钮添加图像!我只是不明白从图像到哪里...

objective-c uibutton ipad ios

0
推荐指数
1
解决办法
63
查看次数

检查双重是否可以分开而没有余数

我需要检查我的双号是否可以在没有余数的情况下分成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)

但我认为还有另一种方式.

.net c#

-1
推荐指数
1
解决办法
451
查看次数