我是XAML和WPF的新手。
按下按钮我想将按钮上绘制的画布从ic_maximize更改为ic_restore,并在再次按下按钮时切换画布。我正在使用mahapps库。你能告诉我怎么做吗?
我尝试了很多不同的StackOverflow链接,但没有一个与我的问题相关。
这是我的最大化按钮的样式。我有#34; IsPressed"触发就绪,但无法确定触发时需要设置的内容.-
<Canvas x:Key="ic_maximize" Width="13.3333" Height="13.3333" Canvas.Left="0" Canvas.Top="0">
<Rectangle Width="11.7333" Height="11.7333" Canvas.Left="2.136" Canvas.Top="-0.536002" Stretch="Fill" StrokeThickness="1.06667" StrokeLineJoin="Round" Stroke="#FF999999"/>
<Rectangle Width="11.7333" Height="11.7333" Canvas.Left="5.36442e-007" Canvas.Top="1.6" Stretch="Fill" StrokeThickness="1.06667" StrokeLineJoin="Round" Stroke="#FF999999" Fill="#FF161616"/>
</Canvas>
<Canvas x:Key="ic_restore" Width="12" Height="12" Canvas.Left="0" Canvas.Top="0">
<Rectangle Width="11.7333" Height="11.7333" Canvas.Left="5.36442e-007" Canvas.Top="0.266666" Stretch="Fill" StrokeThickness="1.06667" StrokeLineJoin="Round" Stroke="#FF999999"/>
</Canvas>
<Style x:Key="ExtendedMaxButtonStyle"
TargetType="{x:Type Button}"
BasedOn="{StaticResource MetroWindowButtonStyle}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid Name="grid" Background="{StaticResource MaxButton.Grid.background}">
<!-- either one of the ic_maximize/ic_restore canvases should come here -->
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="grid" Property="Background" Value="{StaticResource MaxButton.MouseOver.Background}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<!-- What should I write here?-->
</Trigger>
<Trigger Property="IsPressed" Value="False">
<!-- What should I write here?-->
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
答案 0 :(得分:1)
将level_id
放在一起,并在static String clock;
public static void main(String[] args)
{
time();
clock = time();
result();
}
public static String time()
{
Calendar cal = new GregorianCalendar();
int Hour = cal.get(Calendar.HOUR_OF_DAY);
int Min = cal.get(Calendar.MINUTE);
int Sec = cal.get(Calendar.SECOND);
String time = Hour + ":" + Min + ":" + Sec;
return "[" + time + "]";
}
上隐藏一个public static void result()
{
try
{
Print("Loading textures");
Thread.sleep(2500);
Print("Loading sounds");
Thread.sleep(1500);
Print("Loading events");
Thread.sleep(1000);
Print("Loaded");
} catch (Exception e)
{}
}
。
func jsonToString(json: AnyObject){
do {
let data1 = try NSJSONSerialization.dataWithJSONObject(json, options: NSJSONWritingOptions.PrettyPrinted) // first of all convert json to the data
let convertedString = String(data: data1, encoding: NSUTF8StringEncoding) // the data will be converted to the string
print(convertedString) // <-- here is ur string
} catch let myJSONError {
print(myJSONError)
}
}