Hej我正在玩一个使用MVVM的Windows Phone 8应用程序.
我有一个问题,即获取捏缩放的中心并完全理解视口控制器上的边界.最后重新配置viewportcontroller以仍然滚动整个图片.我的xaml代码是:
<Grid>
<StackPanel>
<ViewportControl Bounds="0,0,1271,1381.5" Height="480" Width="800" CacheMode="BitmapCache" RenderTransformOrigin="{Binding KontaktPunkter}" Canvas.ZIndex="1">
<ViewportControl.RenderTransform>
<CompositeTransform x:Name="myTransform" ScaleX="1" ScaleY="1" TranslateX="0" TranslateY="0" />
</ViewportControl.RenderTransform>
<View:Picture/>
</ViewportControl>
</StackPanel>
<View:PopUpUC DataContext="{Binding PopUp}"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)
据我所知,Bounds是我想要滚动的区域,而高度和宽度是控件的窗口尺寸是正确的吗?
回答是的,这是正确的.
到第二部分:)获取捏缩放运动的中心.
public void ZoomDelta(ManipulationDeltaEventArgs e)
{
FrameworkElement Element = (FrameworkElement)e.OriginalSource;
ViewportControl Picture;
Grid PictureGrid;
double MainWidth = Application.Current.RootVisual.RenderSize.Height;
double MainHeight = Application.Current.RootVisual.RenderSize.Width;
if (Element is ViewportControl)
{
Picture = Element as ViewportControl;
}
else
{
Picture = FindParentOfType<ViewportControl>(Element);
}
if (Element is Grid)
{
PictueGrid = Element …Run Code Online (Sandbox Code Playgroud) 嘿大家我试图总结并提出基本问题和我迄今为止无效的想法:S
基本上我的问题是:用户将元素添加到一起,并且我想基于这些图创建新元素,以便可以为用户定义的元素创建新路径.可以说我有一个正方形和一个三角形.用户将其与房屋相结合.现在我想让房子成为用户的元素.为此,我需要元素的路径,我该如何创建它?
我的想法 使用的图形元素基于路径字符串.因此,我希望将这些转换为我稍后可以使用的几何元素.我在下面的答案中使用了AndréMeneses提供的代码,代码在这里复制:
public static Geometry PathMarkupToGeometry(ShieldGearViewModel shieldGearModelRec)
{
string pathMarkup = shieldGearModelRec.Gear.Path;
try
{
string xaml =
"<Path " +
"xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'>" +
"<Path.Data>" + pathMarkup + "</Path.Data></Path>";
var path = System.Windows.Markup.XamlReader.Load(xaml) as System.Windows.Shapes.Path;
// Detach the PathGeometry from the Path
if (path != null)
{
path.Height = shieldGearModelRec.Gear.Height;
path.Width = shieldGearModelRec.Gear.Width;
path.Fill = new SolidColorBrush(Colors.Green);
path.Stretch = Stretch.Fill;
Geometry geometry = path.Data;
//Test not working, exception is thrown
//Rect transRect = new Rect(shieldGearModelRec.Gear.x, shieldGearModelRec.Gear.y, shieldGearModelRec.Gear.Width, shieldGearModelRec.Gear.Height); …Run Code Online (Sandbox Code Playgroud) 我正在一个按钮上移动一个对象,当这个对象在一个按钮上时,我改变了边框的颜色.这没问题,我可以通过绑定,故事板或样式设置器/可视状态来实现.当我在我的模拟器上运行它时,它工作得很好而且流畅,但是当我在Windows手机上运行它时,当国家的边界发生变化时会有一个小的滞后.有办法避免这种情况吗?
1.代码示例
<Button x:Name="Button1" BorderThickness="0" BorderBrush="Transparent">
<Button.Template>
<ControlTemplate x:Name="Control">
<Path x:Name="CountryUser" Style="{StaticResource style_ColorButton}" Data="{Binding UserView.buttonData}" Fill="{StaticResource ButtonBackground}">
<Path.Resources>
<Storyboard x:Name="StoryBoard1">
<ColorAnimation Storyboard.TargetName="User" Storyboard.TargetProperty="(Stroke).(SolidColorBrush.Color)" To="Blue" Duration="0"/>
</Storyboard>
</Path.Resources>
</Path>
</ControlTemplate>
</Button.Template>
Run Code Online (Sandbox Code Playgroud)
并激活
foreach (UIElement x in ElementsAtPoint)
{
f = x as FrameworkElement;
if (f is Path)
{
try
{
h = f as Path;
Storyboard sb = h.Resources["StoryBoard1"] as Storyboard;
sb.Begin();
}
catch
{
}
break;
}
}
Run Code Online (Sandbox Code Playgroud)
额外
仿真器和实际设备之间想到的一个区别是触摸点的准确性.在模拟器中,您使用具有更高分辨率的鼠标.在您使用手指的设备上,精度要低得多,即毫米与像素.
我刚刚在manip_completed_event中用一个简单的计数器和一个断点来测试它.但两种情况下的计数都相同.它只试图运行故事板一次.
Extra2
为了澄清滞后,我看到:
我正在拖动一个平滑地跟随手指的元素,当我进入一个新的按钮时,我拖动的元素停止了一会儿.按钮的颜色发生变化,元素再次移动.
当按钮改变颜色后我向后移动.当我在按钮之间移动时,元素用我的手指平滑移动.
因此,当故事板被激活时存在滞后,并且可以看出我拖动的元素不能跟随手指.
因此,我试图在电话上找到改变可能具有更好性能的颜色的替代方法.因为它在模拟器上工作正常.
我测试了两种不同的lumia 920s和一种lumia 520 …
嘿,我有一个使用silverlight API的Windows Phone 8.1应用程序.我正从blob存储中下载此图像.
图像来自以下链接:https:// [service] .blob.core.windows.net/[imagename] .png,只需使用URI即可在多个浏览器中显示和下载图像.
我现在想将它用作基于blobstorage的imageuri的图像画笔:
// If we have a returned SAS.
BitmapImage myOnlineImage = new BitmapImage();
myOnlineImage.UriSource = new Uri(uploadImage.ImageUri, UriKind.RelativeOrAbsolute);
//ImageOnlineTest.Source = myOnlineImage;
var imageBrush = new ImageBrush
{
ImageSource = myOnlineImage,
Stretch = Stretch.None
};
var source = FindChildShieldCanvas(CanvasImage, imageBrush);
WriteableBitmap wbm = new WriteableBitmap((BitmapImage)myOnlineImage);
ImageOnlineTest.Source = wbm;
Run Code Online (Sandbox Code Playgroud)
该myOnlineImage建立不正确,至少我不能将图像转换为writeablebitmapimage(正从转换零除外),并在另外的图像刷为空,即空.但据我所知,这是方法吗?
所以基本上
如何imagebrush基于https站点的URL 创建?
image azure imagebrush azure-storage-blobs windows-phone-8.1
我在找到的视差图像上有来自gpu :: reprojectImageTo3D的3D点.我现在想要显示这个pointcloud.
如何将找到的pointcloud转换OpenCV为sensor_msgs/PointCloud2?
我不需要发布pointcloud这只是用于调试可视化.是否可以像节点中的图像一样显示它?例如使用pcl?这将是最佳的,因为我的设备可能无法很好地执行RViz(基于在线阅读).
我有windows phone 8.1 silverlight应用程序,我希望使用新框架WNS接收Notfications.
我在package.appxmanifest中:<identity name="4657xxxxxxx" publisher="CN=xxxxx" version="1.0.0.0"/>并将其添加到Mobile Service Hub.
为此,我删除了对MPNS使用的旧引用,并为WNS添加了以下内容:
使用Windows.UI.Notifications;
使用Windows.Networking.PushNotifications;
使用Windows.UI.StartScreen;
这导致了获得channelURI的新方法:
public static PushNotificationChannel CurrentChannel { get; private set; }
public async static Task<bool> UploadChannel()
{
bool newChannel = false;
var channel = await Windows.Networking.PushNotifications.PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
var settings = Windows.Storage.ApplicationData.Current.LocalSettings.Values;
object oldChannel;
settings.TryGetValue("channelURI", out oldChannel);
if ((oldChannel as PushNotificationChannel).Uri != CurrentChannel.Uri)
{
settings.Add("channelURI", CurrentChannel);
newChannel = true;
}
try
{
await App.MobileService.GetPush().RegisterNativeAsync(channel.Uri);
}
catch (Exception exception)
{
CurrentChannel.Close();
HandleRegisterException(exception);
}
CurrentChannel.PushNotificationReceived += CurrentChannel_PushNotificationReceived;
return newChannel; …Run Code Online (Sandbox Code Playgroud) c# silverlight azure azure-mobile-services windows-phone-8.1
嘿希望有人可以提供帮助.
我在小组中开发了许多不同的项目,我们现在想要将它们结合起来.因此,我包括了这些项目.在启动项目中,我包含对其他项目的引用.然后我使用另一个stackoverflow线程中的代码:
这给了我以下几点
NavigationService.Navigate(new Uri("/MVVMTestApp;/component/View/MainPage.xaml", UriKind.Relative));
Run Code Online (Sandbox Code Playgroud)
该项目建立并运行.但是当我按下应该激活代码的按钮时,在执行该行之后/期间会出现错误.
中断错误位于MainPage.g.cs文件中,如下所示:
namespace MVVMTestApp {
public partial class MainPage : Microsoft.Phone.Controls.PhoneApplicationPage {
internal System.Windows.Controls.TextBlock MainPageTitle;
internal System.Windows.Controls.TextBlock LEgE;
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
*******System.Windows.Application.LoadComponent(this, new System.Uri("/MVVMTestApp;component/View/MainPage.xaml", System.UriKind.Relative));**
this.MainPageTitle = ((System.Windows.Controls.TextBlock)(this.FindName("MainPageTitle")));
this.LEgE = ((System.Windows.Controls.TextBlock)(this.FindName("LEgE")));
}
}
}
Run Code Online (Sandbox Code Playgroud)
我插入星星的那条线就是它打破的地方.我需要做些什么来使它工作?
额外
正如在评论中所说,我需要在组件之前包含一个前锋"/",这是奇怪的,因为它没有在任何地方使用,否则像上面的链接和这个链接
http://www.geekchamp.com/tips/wp7-navigating-to-a-page-in-different-assembly
但是包括forwardslash我得到一个错误,那就是我没有指向任何xaml文件.排除转发,我发现XamlParseException ....
所以我仍然有导航到另一个项目中的视图的问题.
奇
我现在不必在组件之前拥有领先的前锋.只要我编写MVVMTestAppAssembly.我查看了汇编文件,找不到这个包括=?
看完msdn后我试了一下 http://msdn.microsoft.com/en-us/library/cc296240%28v=vs.95%29.aspx
但仍然没有运气,导航工作
OVerview of reference并包含元素的完整路径


一种解决方案 如一个答案中所述,一种解决方案是使用Windows phone类库.但是当我使用MVVM结构时,我无法使viewmodelLocator工作.因此,这对我来说不是解决方案.
但是如果你使用MVVM,我需要另一个解决方案.希望有人对此有所了解. 另一种解决方案 …
c# mvvm navigationservice visual-studio-2012 windows-phone-8
我有一个在Azure App Service上运行的控制器 - Mobile.跟踪显示以下代码运行正常,直到db.SaveChanges()失败.
var telemetry = new Microsoft.ApplicationInsights.TelemetryClient();
telemetry.TrackTrace("Create User");
using (BCMobileAppContext db = new BCMobileAppContext())
{
string Username_NoSpaces = username.Username.Replace(" ", "");
var user = db.Users.FirstOrDefault(u => u.Username_NoSpaces == Username_NoSpaces || u.MicrosoftToken == this.User.Identity.Name);
telemetry.TrackTrace("1");
if (user == null && !Username_NoSpaces.Contains(","))
{
telemetry.TrackTrace("2");
DateTime now = DateTime.UtcNow;
telemetry.TrackTrace("3");
string username_noSpaces = username.Username.Replace(" ", "");
DataObjects.User userItem = new DataObjects.User() { Created = now, UserId = this.User.Identity.Name, MicrosoftToken = this.User.Identity.Name, Username_NoSpaces = username_noSpaces, Update = now, …Run Code Online (Sandbox Code Playgroud) c# asp.net entity-framework azure-mobile-services azure-api-apps
在 Visual Studio 2013 和 2015 中运行一段代码时,我得到两种不同的结果。在 Visual Studio 2015 上,我得到了一个 NullReference,在 2013 年它按应有的方式工作。此外,Visual Studio 2015 在 Windows 8.1 上的 Windows 10 和 2013 上运行。这段代码是:
private static T FindParentOfType<T>(DependencyObject o)
{
dynamic parent = VisualTreeHelper.GetParent(o);
return parent.GetType().IsAssignableFrom(typeof(T)) ? parent : FindParentOfType<T>(parent);
}
Run Code Online (Sandbox Code Playgroud)
代码是这样调用的:
Grid RiskGrid = FindParentOfType<Grid>(ChampViewModelSel);
Run Code Online (Sandbox Code Playgroud)
错误是Nullreference,当检查IsAssginableFrom,因为在VS2015找到一个帆布代替了在VS2013中找到的希望电网?
堆栈跟踪
Run Code Online (Sandbox Code Playgroud)StackTrace " at Microsoft.CSharp.RuntimeBinder.SymbolTable.GetOriginalTypeParameterType(Type t)\r\n at Microsoft.CSharp.RuntimeBinder.SymbolTable.AreTypeParametersEquivalent(Type t1, Type t2)\r\n at Microsoft.CSharp.RuntimeBinder.SymbolTable.LoadMethodTypeParameter(MethodSymbol parent, Type t)\r\n at Microsoft.CSharp.RuntimeBinder.SymbolTable.LoadSymbolsFromType(Type originalType)\r\n at Microsoft.CSharp.RuntimeBinder.SymbolTable.AddMethodToSymbolTable(MemberInfo member, AggregateSymbol callingAggregate, MethodKindEnum kind)\r\n at Microsoft.CSharp.RuntimeBinder.SymbolTable.AddNamesInInheritanceHierarchy(String …
c# windows visual-studio visual-studio-2013 visual-studio-2015
让 \xe2\x80\x99s 说我有不同的后端服务,在 azure api 管理 (apim) 中公开它们的 api。不同的服务依赖于不同的安全方法,例如jwt令牌和订阅密钥。后端开发人员指定这些差异并使用 OpenApi 规范 (OAS) 将其上传到 apim。然后我发现安全定义被忽略,那么开发人员必须在哪里指定此信息?而是在描述中?或者在 apim 中传递安全信息的正确方法是什么。
\n此外,apim 可以设置有关安全的策略。这些政策也没有在美洲国家组织中公开。然而,除了订阅密钥之外,这只是默认行为,即使在 apim 的 api 设置中禁用了需要订阅的标签,订阅密钥仍然存在于 OAS 中。
\n那么,当 OAS 中不存在后端服务安全性和 apims 安全性时,如何告知用户相关信息呢?我是否缺少某些配置?
\n我的 apim 的想法是拥有不同的后端服务供应商,这样他们就可以有不同的安全级别 - 可以在 OAS 中指定 - 但不会在 apim 的导出版本中提供任何内容。
\n此外,我作为 apim 的所有者将设置一些安全设置 - 这些设置仍然不会出现在 OAS 中。那么消费者应该怎么做才能了解如何使用下载的 OAS\xe2\x80\x99s 中公开的后端端点呢?
\nc# ×7
azure ×3
mvvm ×2
asp.net ×1
geometry ×1
image ×1
imagebrush ×1
openapi ×1
opencv ×1
path ×1
pathgeometry ×1
performance ×1
point-clouds ×1
ros ×1
silverlight ×1
viewport ×1
windows ×1
xaml ×1
zoom ×1