Как совместно использовать числовую константу между xaml и c# в Silverlight

Я думаю, что вы ищете не timeit, а время :

import time

results = []

for a in a_list:
    for b in b_list:
        start_time = time.time()
        # do something
        end_time = time.time()
        total_time = end_time - start_time
        if total_time > 1:
             break  # or exit, whichever

        results.append([a, b, end_timer])

11
задан casterle 14 May 2009 в 15:42
поделиться

1 ответ

Поместите их в свое приложение или ресурсы страницы:

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:sys="clr-namespace:System;assembly=mscorlib">
    <Application.Resources>
        <sys:Int32 x:Key="QPS">8</sys:Int32>
    </Application.Resources>
</Application>

Затем вы можете получить к ним доступ с помощью кода, подобного этому:

if (Application.Current.Resources.Contains("QPS"))
{
    int callsPerSecond = (int) Application.Current.Resources["QPS"];
}

и через Xaml, например,

<TextBlock Text="{StaticResource QPS}"/>
19
ответ дан 3 December 2019 в 06:22
поделиться
Другие вопросы по тегам:

Похожие вопросы: