![](/img/trans.png)
[英]How do I make my TextBlocks be the correct sizes in my C# XAML Windows 8.1 app?
[英]How do I make a user control display as pop up in windows 8.1 c# and xaml
我有一個顯示項目列表的頁面。 如何使用戶控件顯示有關在c#xaml中單擊(選中)的項目的詳細信息。
如果有人也可以建議鏈接到博客文章或文章,以詳細說明如何執行此操作
盡管這不是SO的目的,但我還是會回答:
您正在尋找的可能是flyout
。 您可以在此處閱讀快速入門
例
您可以使用AttachedFlyout
附加屬性將彈出控件添加到另一個UIElement中:
<Grid x:Name="RootGrd">
<FlyoutBase.AttachedFlyout>
<Flyout x:Name="MainFlt">
<Border BorderBrush="White" BorderThickness="3" Margin="0,0,0,10">
<StackPanel>
<TextBlock Text="{Binding Prop1}"/>
<TextBlock Text="{Binding Prop2}"/>
<TextBlock Text="{Binding Prop3}"/>
<Button Content="Close" Click="Button_Click"/>
</StackPanel>
</Border>
</Flyout>
</FlyoutBase.AttachedFlyout>
<ListView x:Name="MainLvw" SelectionChanged="MainLvw_SelectionChanged" Background="DeepSkyBlue">
<ListView.ItemTemplate>
<DataTemplate>
<Border BorderBrush="White" BorderThickness="3" Margin="0,0,0,10">
<StackPanel>
<TextBlock Text="{Binding Prop1}"/>
<TextBlock Text="{Binding Prop2}"/>
<TextBlock Text="{Binding Prop3}"/>
</StackPanel>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
然后在后面的代碼中,調用FlyoutBase.ShowAttachedFlyout()
以顯示彈出窗口:
private void MainLvw_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var sndr = (ListView)sender;
var item = (SampeClass)sndr.SelectedItem;
RootGrd.DataContext = item;
FlyoutBase.ShowAttachedFlyout(RootGrd);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
MainFlt.Hide();
}
您可以在我的github上找到一個示例解決方案,其中顯示了已實現的解決方案: GitHub repo
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.