
我有一个带有1列数据网格的应用程序(现在).如何从数据网格中删除第二个空列,以便只在数据网格中显示包含数据的列.
这是这个问题的后续行动.
我正在尝试绘制一个填充三角形,使用DrawingContext它来渲染DrawingVisual
目前,我已设法使用以下C#代码绘制三角形的轮廓:
private DrawingVisual CreateTriangle()
{
DrawingVisual triangle = new DrawingVisual();
using ( DrawingContext dc = triangle.RenderOpen() )
{
Pen drawingPen = new Pen(Brushes.Black,3);
dc.DrawLine(drawingPen, new Point(0, 50), new Point(50, 0));
dc.DrawLine(drawingPen, new Point(50, 0), new Point(50, 100));
dc.DrawLine(drawingPen, new Point(50, 100), new Point(0, 50));
}
return triangle;
}
Run Code Online (Sandbox Code Playgroud)
我明白了:

如何绘制一个三角形,除了我绘制的边框还有红色填充?

我有一个ItemsControl在我的程序包含单选按钮的列表.
<ItemsControl ItemsSource="{Binding Insertions}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<RadioButton GroupName="Insertions"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)
如何以MVVM方式在组 Insertions中找到所选的单选按钮?
我在互联网上找到的大多数例子都涉及IsChecked在转换器的帮助下设置绑定属性的各个布尔属性.
是否有ListBox SelectedItem我可以绑定的等价物?
我已经搜索并了解如何使用在WPF中保存图像BmpBitmapEncoder.我的程序有一个MVVM视图,我想保存为图像.是否可以将其设置为BitmapFrame可以对其进行编码?如果是这样,是否有在线教程?
下面列出的是我想要保存的视图.
<Grid>
<view:OverallView Grid.Row="1"
Visibility="{Binding IsOverallVisible,Converter={StaticResource B2VConv}}"
/>
</Grid>
Run Code Online (Sandbox Code Playgroud)
OverallView 是一个用户控件.
如果将视图设置为a,BitmapFrame则可以将哪些wpf元素设置为BitmapSource/Frame?
我正在尝试使用部分创建带标签的侧边栏,如WPF中的以下内容.我考虑过一些方法,但有更简单,更优雅的方法吗?
方法1:ListBox
使用ListBox和将SelectedItem绑定到一个值,右边的内容控件绑定到该值.为了区分标题和部分,我使用DataTemplate选择器.
方法2:RadioBUtton/Check Boxes/ToggleButtons
使用单选按钮,我将所选项目绑定到内容控件.但是,由于WPF错误,我将不得不使用值转换器将它们链接在一起.


目前,如果我有一个<TextBlock>字体大小为200的元素,整个元素占用的空间比需要的多得多.

蓝色轮廓(来自Blend)显示元素占用的空间,当需要的时候很容易就会有一半.无论如何,我可以消除那个空间,使我的元素没有这么多间隔?我已经尝试过边距,填充等,但大多数方法似乎都不起作用.

理想情况下,我希望<textblock>仅占用红色框表示的空间量
编辑:

为了回应stijn7,确实为其他字母(g,p,q等)保留了一些空间.但是顶部仍然有很多空间(1是Segoe UI中最高的字符).如果无法剪切文本块,无论如何我是否可以调整它以使其没有浪费的空间?
我正在尝试在WP8.1(WinRT)中发生地理围栏事件(进入/退出)时触发BackgroundTask.我写了一个示例应用程序试图让它工作,但似乎无法这样做.
到目前为止,这些是我试图让Geofences在后台工作的步骤:
LocationTrigger(LocationTriggerType.Geofence);我在我的app.manifest中启用了:
BackgroundTask.GeofenceBackgroundTask我的后台任务位于一个单独的项目中,标题为BackgroundTask.它是一个WindowsRT组件,包含一个类GeofenceBackgroundTask.

该项目的代码可以在[link](https://github.com/kiangtengl/GeofenceSample)找到:
在模拟器中运行代码
将位置设置为:纬度= 01.3369,经度= 103.7364

单击Register Geofence + BackgroundTasks按钮
退出应用程序(按主页按钮)
将当前位置更改为距离您之前设置的位置100米.应该弹出通知.
public static async Task GetLocationCapabilities()
{
try
{
var geolocator = new Geolocator();
await geolocator.GetGeopositionAsync();
var backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync();
Debug.WriteLine("background access status" + backgroundAccessStatus);
}
catch (UnauthorizedAccessException e)
{
Debug.WriteLine(e);
}
catch (TaskCanceledException e)
{
Debug.WriteLine(e);
}
} …Run Code Online (Sandbox Code Playgroud) windows geolocation windows-runtime windows-phone-8 windows-phone-8.1
我正在尝试将我的应用程序的自定义控件颜色与Windows 7中使用的颜色相匹配.但是,我似乎无法找到Windows 7使用的所有颜色的完整列表.是否有包含这些颜色的内置类,或者我是否必须为我想要设计的每个控件使用颜色选择器.
我正试图从Windows Phone 8.1中的Geoposition获取CivicAddress
我尝试使用以下代码:
// Get Current Location
var geolocator = new Geolocator();
geolocator.DesiredAccuracyInMeters = 100;
var position = await geolocator.GetGeopositionAsync();
// Get Country
var country = position.CivicAddress.Country;
Run Code Online (Sandbox Code Playgroud)
由于CivicAddress字段为null,因此抛出NullReferenceException.我知道没有为Windows 8提供CivicAddress提供程序.我想检查是否是Windows Phone 8.1的情况.如果是这样,我如何获取/编写CivicAddress提供程序?
c# geolocation windows-runtime windows-phone-8 windows-phone-8.1
wpf ×8
c# ×7
.net ×4
geolocation ×2
mvvm ×2
windows ×2
wpf-controls ×2
binding ×1
c#-4.0 ×1
controls ×1
datagrid ×1
radio-button ×1
silverlight ×1
xaml ×1