在WPF中,我想TabControl
在我的代码中获取a的角落位置,因此我可以在显示时相应地设置ToolWindow的位置.
我如何获得给定的位置UIElement
?
buildingInfoWindow = new BuildingInfoWindow(); // BuildingWindow : System.Windows.Window
buildingInfoWindow.Owner = this;
//buildingInfoWindow.Left = ?; // relative X coordinate of my TabControl
//buildingInfoWindow.Top = ?; // relative Y coordinate of my TabControl
Run Code Online (Sandbox Code Playgroud) 这里曾经多次询问过类似的问题,但它们似乎都没有给我我想要的东西.我正在使用Windows Phone上的Bing Map控件,我想添加一个椭圆,可以根据缩放更改进行正确缩放.这可以使用多边形线和多边形来完成,但是没有从MapShapeBase派生的椭圆类型.我已经尝试了各种方法,但它们需要使用像素大小并捏造数学以使其与地理坐标对齐.我想创建一个椭圆,其中心和x/y尺寸以米为单位,其余部分由框架完成.看起来很简单.我错过了某个地方吗?我的另一种方法是在折线中绘制365个线段,但这看起来非常难看,而且由于中心可以移动,我需要绑定每个线段的位置.这看起来非常重.还有其他想法吗?
[具体来说,我想在当前位置周围添加一个"GPS准确度"指示器.]
我们如何设置按钮的不同状态,尤其是按下状态.我知道我们可以使用表达式混合设置它,但我仍然不能这样做.另外,我们可以编辑自定义按钮的按下状态吗?
谢谢
我有一个包含一个简单按钮的ItemTemplate.当我单击此按钮时,我需要一种方法来识别单击的行以拉出绑定到列表框的项目.
XAML
<ListBox Name="DemoBox" SelectionChanged="listBox_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="150">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="400"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid Height="120" Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
Text="{Binding SomeObjProperty}"/>
</Grid>
<Grid Height="120" Grid.Column="1" Margin="0,-12,0,0">
<Button Click="ShowStuffOnMap_Click">
<Button.Background>
<ImageBrush ImageSource="images/arrow.png"/>
</Button.Background>
</Button>
</Grid>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
点击处理程序
private void ShowStuffOnMap_Click(object sender, RoutedEventArgs e)
{
//sender is the button so ...
}
Run Code Online (Sandbox Code Playgroud)
先感谢您
我正在为Windows Phone 8在Silverlight中开发一个Flash Light应用程序.目前我在一个问题上深深陷入使用"Microsoft.Phone.Media.Extended"程序集.适用于Windows Phone 7的Flash Light应用程序已经在Windows Phone Marketplace中运行,它对Windows Phone 7工作得非常好,但由于"Microsoft.Phone.Media.Extended"dll,它不能用于Windows Phone 8.
将WP7应用程序转换为wp8并运行后,我收到了此类错误消息:
无法加载文件或程序集"Microsoft.Phone.Media.Extended,Version = 7.0.0.0,Culture = neutral,PublicKeyToken = 24eec0d8c86cda1e"或其依赖项之一.系统无法找到特定文件."
根据Windows Phone特定功能的以下链接:http: //msdn.microsoft.com/en-us/library/windowsphone/develop/jj206947(v=vs.105).aspx
如果您使用反射来访问此程序集中的API,因为它们未公开,您的应用程序可能会在Windows Phone 8设备上失败.删除对此程序集的调用并使用公开的媒体API.
我不了解如何使用公开的媒体API.我在Windows Phone 7中使用了Microsoft.Phone.Media.Extended使用reflaction.是否有任何直接的方法来访问Windows Phone 8中的Microsoft.Phone.Media.Extended或其他解决方法?
谢谢.
================================================== ========================编辑问题:
嗨,
根据线程,我们使用"VideoTorchMode"枚举来打开手电筒.据此,我使用Windows.Phone.Media.Capture命名空间使用AudioVideoCaptureDevice类,代码如下:
var objDevice = await AudioVideoCaptureDevice.OpenAsync(CameraSensorLocation.Back, AudioVideoCaptureDevice.GetAvailableCaptureResolution(CameraSensorLocation.Back).First());
objDevice .SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.On);
Run Code Online (Sandbox Code Playgroud)
我想保持闪光灯亮,但不捕捉视频.所以,我还没有初始化视频捕获代码.问题是,我还没有WP8,在模拟器中我无法测试这个.
任何人都可以确认,一旦我把这个代码,我的应用程序将作为Flashlight-X工作,其中灯将打开而不会闪烁,它也不会在WP8中崩溃.
谢谢
我正在玩ANTLR,并希望创建一个这样的函数:
MOVE x y z pitch roll
Run Code Online (Sandbox Code Playgroud)
这会产生以下AST:
MOVE
|---x
|---y
|---z
|---pitch
|---roll
Run Code Online (Sandbox Code Playgroud)
到目前为止,我已经尝试过没有运气,并且我不断让AST将参数作为兄弟姐妹,而不是孩子.
代码到目前为止:
C#:
class Program
{
const string CRLF = "\r\n";
static void Main(string[] args)
{
string filename = "Script.txt";
var reader = new StreamReader(filename);
var input = new ANTLRReaderStream(reader);
var lexer = new ScorBotScriptLexer(input);
var tokens = new CommonTokenStream(lexer);
var parser = new ScorBotScriptParser(tokens);
var result = parser.program();
var tree = result.Tree as CommonTree;
Print(tree, "");
Console.Read();
}
static void Print(CommonTree tree, string indent)
{ …
Run Code Online (Sandbox Code Playgroud) 我试图将我的代码编辑为以下但似乎不是正确的方法:
public int Compare(object x, object y)
{
string s1 = (string)x;
string s2 = (string)y;
return DateTime.Compare(DateTime.ParseExact(s1.Substring(1), "MMddyyyy", CultureInfo.InvariantCulture),
DateTime.ParseExact(s2.Substring(1), "MMddyyyy", CultureInfo.InvariantCulture));
}
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();
if (scheduleListBox.Items.Count == 0)
{
try
{
//Get all the directories name that start with "a"
fileNames = myStore.GetDirectoryNames("a*");
//Sort according to the schedule month
//Array.Sort(fileNames);
Array.Sort(new Compare(fileNames));
Run Code Online (Sandbox Code Playgroud)
我在数组列表中有a08102011格式的数据.
其中08是月, 10是日, 2011是年.
怎么能按照那种方式排序?
a08102011 …
我在c#上课
public class CompositeResource : Control
{
[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public ResourceCollection Resources { get { return _resources; } }
}
public class Resource
{
[Bindable(true), DefaultValue(""), Editor("System.Web.UI.Design.UrlEditor, System.Design, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor)), Description("Specifies the URL of a resource to reference in the CompositeControl. The URL may be relative, root relative or absolute."), UrlProperty]
public String Url { get; set; }
[Bindable(true), DefaultValue(""), Description("Specifies the name of a resource to be used as a reference in the CompositeControl. The ReferenceName is typically used …
Run Code Online (Sandbox Code Playgroud) 如果我有listbox Item
,我怎么把它index
列入清单?我有一个databound
应用程序,列出用户以前保存的数据.但是,我希望能够使用a删除列表中的特定数据contextMenu
.
那么如何获取项目的列表索引以显示上下文菜单?
以NSTimer为例.构造时,除第一个(方法名称)之外的所有参数都命名为:
NSTimer *timer =
[NSTimer
scheduledTimerWithTimeInterval: seconds
target: self
selector: @selector(timerTick:)
userInfo: nil
repeats: repeats
];
Run Code Online (Sandbox Code Playgroud)
为什么第一个参数没有命名?即
NSTimer *timer =
[NSTimer scheduledTimerWithTimeInterval
interval: seconds
target: self
selector: @selector(timerTick:)
userInfo: nil
repeats: repeats
];
Run Code Online (Sandbox Code Playgroud)
这背后是否有一些语言设计决策?它提供了一些我在这里看不到的灵活性吗?
c# ×4
xaml ×2
antlr ×1
antlr3 ×1
antlrworks ×1
bing-maps ×1
data-binding ×1
math ×1
objective-c ×1
position ×1
uielement ×1
wpf ×1