有没有办法在地铁应用中获得x:uid
控制属性。
<Button x:Name="ViewPanelButton"
Grid.Column="3"
Grid.Row="0"
x:Uid="s_View"
VerticalAlignment="Bottom"
Margin="5,0,0,5"
HorizontalAlignment="Center"
Style="{StaticResource MainPageButtonStyle}"
Click="ViewPanelButton_Click"
Height="22"
Width="Auto" />
我想从代码后面获取这个x:Uid属性。它是WPF的财产,但不是地铁。有没有办法在Metro应用程序中获取此属性?
答案 0 :(得分:0)
遗憾的是,我已向平台团队确认您尚未执行此操作。
但是,您可以手动设置默认语言。
public void Setup()
{
var r = Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView();
r.QualifierValues.MapChanged += QualifierValues_MapChanged;
}
public void Cleanup()
{
var r = Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView();
r.QualifierValues.MapChanged -= QualifierValues_MapChanged;
}
void QualifierValues_MapChanged(Windows.Foundation.Collections.IObservableMap<string, string> sender, Windows.Foundation.Collections.IMapChangedEventArgs<string> @event)
{
// you can fetch the default, and test if you need change
string d;
var m = Windows.ApplicationModel.Resources.Core.ResourceManager.Current.DefaultContext.QualifierValues;
if (!m.TryGetValue("Language", out d))
return;
// you can set your own or use the first (default)
var l = Windows.System.UserProfile.GlobalizationPreferences.Languages.First();
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = l;
}
祝你好运!