UWP - InkCanvas 无响应
UWP - No response from InkCanvas
我是第一次构建 UWP 应用。我正在尝试使用我放在页面上的 InkCanvas,但我似乎根本无法在上面绘图。
我正在使用鼠标尝试绘图 - 我不知道如果这有什么不同,你是否真的需要使用笔或触摸屏。
谁能帮我这个?我究竟做错了什么?
XAML代码:
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="230" />
</Grid.RowDefinitions>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="100*"/>
<RowDefinition/>
</Grid.RowDefinitions>
<InkCanvas x:Name="inkCanvas" Grid.RowSpan="2" />
</Grid>
<ListView x:Name="lvItems" ItemsSource="{x:Bind data}" IsItemClickEnabled="False" Margin="60,60,60,0" SelectionMode="None">
<ListView.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="91*"/>
<ColumnDefinition Width="453*"/>
<ColumnDefinition Width="150*"/>
<ColumnDefinition Width="210*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Item" Grid.Column="0" FontWeight="Normal"/>
<TextBlock Text="Detail" Grid.Column="1" FontWeight="Normal"/>
<TextBlock Text="Yes/No" Grid.Column="2" FontWeight="Normal"/>
<TextBlock Text="N/A" Grid.Column="3" FontWeight="Normal"/>
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="20,0,20,0">
<TextBlock FontSize="18" Text="{Binding ItemNumber}" HorizontalAlignment="Right" Margin="0,0,20,0" Width="32" ></TextBlock>
<TextBlock FontSize="18" Text="{Binding ItemDetails}" HorizontalAlignment="Right" Width="400"></TextBlock>
<CheckBox IsChecked="{Binding YesNo}" Margin="20,0,0,0" Width="5"></CheckBox>
<CheckBox IsChecked="{Binding NotApplicable}" Margin="20,0,0,0" Width="5"></CheckBox>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button x:Name="btnOpenFile" Content="Open Data File" HorizontalAlignment="Left" Margin="60,14,0,0" VerticalAlignment="Top" Click="btnOpenFile_Click" Height="32" Width="118"/>
<Button x:Name="btnExportToPDF" Content="Export to PDF" HorizontalAlignment="Left" Margin="188,14,0,0" VerticalAlignment="Top" Height="32" Width="111"/>
</Grid>
我自己设法解决了这个问题。
您需要定义哪些 inputs/devices 可以在 canvas 上绘制。
public MainPage()
{
this.InitializeComponent();
inkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen;
}
我是第一次构建 UWP 应用。我正在尝试使用我放在页面上的 InkCanvas,但我似乎根本无法在上面绘图。
我正在使用鼠标尝试绘图 - 我不知道如果这有什么不同,你是否真的需要使用笔或触摸屏。
谁能帮我这个?我究竟做错了什么?
XAML代码:
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="230" />
</Grid.RowDefinitions>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="100*"/>
<RowDefinition/>
</Grid.RowDefinitions>
<InkCanvas x:Name="inkCanvas" Grid.RowSpan="2" />
</Grid>
<ListView x:Name="lvItems" ItemsSource="{x:Bind data}" IsItemClickEnabled="False" Margin="60,60,60,0" SelectionMode="None">
<ListView.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="91*"/>
<ColumnDefinition Width="453*"/>
<ColumnDefinition Width="150*"/>
<ColumnDefinition Width="210*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Item" Grid.Column="0" FontWeight="Normal"/>
<TextBlock Text="Detail" Grid.Column="1" FontWeight="Normal"/>
<TextBlock Text="Yes/No" Grid.Column="2" FontWeight="Normal"/>
<TextBlock Text="N/A" Grid.Column="3" FontWeight="Normal"/>
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="20,0,20,0">
<TextBlock FontSize="18" Text="{Binding ItemNumber}" HorizontalAlignment="Right" Margin="0,0,20,0" Width="32" ></TextBlock>
<TextBlock FontSize="18" Text="{Binding ItemDetails}" HorizontalAlignment="Right" Width="400"></TextBlock>
<CheckBox IsChecked="{Binding YesNo}" Margin="20,0,0,0" Width="5"></CheckBox>
<CheckBox IsChecked="{Binding NotApplicable}" Margin="20,0,0,0" Width="5"></CheckBox>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button x:Name="btnOpenFile" Content="Open Data File" HorizontalAlignment="Left" Margin="60,14,0,0" VerticalAlignment="Top" Click="btnOpenFile_Click" Height="32" Width="118"/>
<Button x:Name="btnExportToPDF" Content="Export to PDF" HorizontalAlignment="Left" Margin="188,14,0,0" VerticalAlignment="Top" Height="32" Width="111"/>
</Grid>
我自己设法解决了这个问题。
您需要定义哪些 inputs/devices 可以在 canvas 上绘制。
public MainPage()
{
this.InitializeComponent();
inkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen;
}