我正在尝试让我的NavViewItems像按钮一样操作,而不是切换按钮。我不希望NavViewItem在选中后粘贴。
private void NavView_SelectionChanged(
NavigationView sender,
NavigationViewSelectionChangedEventArgs args)
{
if (args.IsSettingsSelected)
{
NavView.Header = "Settings";
//rootFrame.Navigate(typeof(SettingsPage));
}
else if (args.SelectedItem != null)
{
NavigationViewItem item
= args.SelectedItem as NavigationViewItem;
NavView.Header = item.Tag;
// Unclick/Unselect NavViewItem Here <--
}
}
}
<Page ... >
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<NavigationView
RequestedTheme="Dark"
x:Name="NavView"
Header="Welcome"
SelectionChanged="NavView_SelectionChanged">
<NavigationView.MenuItems>
<NavigationViewItem
Icon="Home"
Content="Home"
Tag="Home"
Background="Maroon"
Foreground="White"/>
<NavigationViewItem
Icon="Back"
Content="PrevPage"
Tag="Back"
Background="Maroon"
Foreground="White"/>
<NavigationViewItem
Icon="Globe"
Content="Enter Info1"
Tag="EnterCompany"
Background="DarkGreen" Foreground="White"/>
<NavigationViewItem
Icon="PostUpdate"
Content="Enter Info2"
Tag="EnterJob"
Background="DarkGreen" Foreground="White"/>
<NavigationViewItem
Icon="Globe"
Content="Query Info1"
Tag="QueryCompany"
Background="DarkBlue" Foreground="White"/>
<NavigationViewItem
Icon="PostUpdate"
Content="Query Info2"
Tag="QueryJob"
Background="DarkBlue"
Foreground="White"/>
</NavigationView.MenuItems>
<Frame x:Name="ContentFrame" />
</NavigationView>
</Grid>
</Page>
我知道这样做的唯一方法就是扔掉导航控件并返回只使用网格上的按钮...或者可以定义一个模板来关闭所选的突出显示...无论如何,我在尝试坚持使用Nav Control只是为了标准并获得自动调整大小的功能...
答案 0 :(得分:0)
将SelectionIndex从SelectionChanged事件设置为null,以使导航选项卡取消遮挡并像按钮一样操作。在1803之前,SelectedIndex属性只能从SelectionChanged事件中读取,并且需要使用Dispatcher进行设置。
public void HandleRequest(WebhookModel model)
{
var strRequest = "cmd=_notify-validate&" + ipnContext.RequestBody;
var webRequest = FormRequest(strRequest);
var requestStream = _webRequestWrapper.GetRequestStream();
var responseStream = _webRequestWrapper.GetResponse().GetResponseStream();
using (StreamReader reader = new StreamReader(responseStream))
{
model.Verification = reader.ReadToEnd();
}
}
private WebRequest FormRequest(string strRequest)
{
var webRequest = WebRequest.Create("some url is over here");
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = strRequest.Length;
return webRequest;
}
然而,在1803年,这个技巧不再起作用,尽管SelectedItem属性不再是来自SelectionChanged事件的只读。在1803中使用Dispatcher将SelectionIndex设置为null会导致无限递归循环。