我在<Style TargetType="{x:Type Button}">
<Setter Property="RenderTransformOrigin" Value="0.5 0.5" />
<Setter Property="RenderTransform">
<Setter.Value>
<RotateTransform />
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=btn , Path=IsPressed}" Value="True" />
<Condition Binding="{Binding ElementName=chk , Path=IsChecked}" Value="True" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard TargetProperty="RenderTransform.Angle">
<DoubleAnimation From="0"
To="5"
Duration="0:0:0.05"
AutoReverse="True"
FillBehavior="Stop" />
<DoubleAnimation BeginTime="0:0:0.05"
From="5"
To="-5"
Duration="0:0:0.1"
AutoReverse="True"
FillBehavior="Stop" />
<DoubleAnimation BeginTime="0:0:0.2"
From="-5"
To="0"
Duration="0:0:0.1"
AutoReverse="False"
FillBehavior="Stop" />
</Storyboard>
</BeginStoryboard>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>
</Style.Triggers>
</Style>
中创建了一个可能类似于以下内容的类:
C#
我想在public class Foo
{
public T DoWork<T>(string name) where T:class,new()
{
// this all works
}
}
中使用它,但是不确定如何使用。
我尝试了一些在MSDN上发现的事情,但我想我还是不明白。
我有一个看起来像这样的课
Vb.net
我最后一次尝试是:
Public Class Fooer
Property FirstName() as String
Property LastName() as String
End Class
但是这个没有编译。
有人可以解释如何实现吗?
答案 0 :(得分:3)
要在VB.Net中调用泛型函数,语法如下:
import random
import tkinter as tk
import webbrowser
class TestClass:
counter = {}
root = tk.Tk()
def __init__(self):
self.root.title('Test')
self.topframe = tk.Frame(self.root)
self.topframe.pack( side = tk.TOP, pady=30)
self.bottomframe = tk.Frame(self.root)
self.bottomframe.pack( side = tk.BOTTOM )
self.button = tk.Button(self.topframe, text='Click', command = self.output_value)
self.button.pack(side="left", fill="both", expand=True)
self.root.mainloop()
def callback(event):
webbrowser.open_new(event.widget.cget("text"))
def plus1(self,url):
self.counter[url] = int(self.counter[url]) + 1
self.DisplayButton["text"]=str(self.counter[url])
def neg1(self,url):
self.counter[url] = int(self.counter[url]) - 1
self.DisplayButton["text"]=str(self.counter[url])
####define the function that the submit button will do
def output_value(self):
urls = ["http://www.google.com", "http://www.facebook.com"]
i=0
for url in urls:
self.counter[url] = random.randint(1, 10)
lbl = tk.Label(self.bottomframe, text=url, fg="blue", cursor="hand2")
lbl.grid(row=i, column=1)
lbl.bind("<Button-1>", self.callback)
self.DisplayButton = tk.Button(self.bottomframe, text = self.counter[url])
self.DisplayButton.grid(row=i, column=2)
self.DisplayButton.config(height = 1, width = 1 )
self.Plus1Button = tk.Button(self.bottomframe, text = "+1", command=self.plus1(url), bg="green")
self.Plus1Button.grid(row=i, column=3)
self.Plus1Button.config(height = 1, width = 1 )
self.Neg1Button = tk.Button(self.bottomframe, text = "-1", command=self.neg1(url), bg="green")
self.Neg1Button.grid(row=i, column=4)
self.Neg1Button.config(height = 1, width = 1 )
i += 1
if __name__ == "__main__":
TestClass()