Hi
If you using MS .NET DocumentViewer and you want customize Find field
there some ways.
In my example i can change text "Type text to find..." to other one ("Find me!") and also disable alefHamza field
ContentControl findToolBar = documentViewer.Template.FindName("PART_FindToolBarHost", documentViewer) as ContentControl;
if (findToolBar == null) return;
Type baseType = findToolBar.Content.GetType();
MemberInfo[] dynMethod = baseType.GetMember("OptionsMenuItem", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo alefHamzaField = (dynMethod[0] as FieldInfo);
System.Windows.Controls.MenuItem menuItem = alefHamzaField.GetValue(findToolBar.Content) as System.Windows.Controls.MenuItem;
menuItem.Visibility = System.Windows.Visibility.Collapsed;
dynMethod = baseType.GetMember("FindTextLabel", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo findTextLabel = (dynMethod[0] as FieldInfo);
System.Windows.Controls.Label lbl = findTextLabel.GetValue(findToolBar.Content) as System.Windows.Controls.Label;
lbl.Content = "Find me!"
Thanks for watching!
If you using MS .NET DocumentViewer and you want customize Find field
there some ways.
In my example i can change text "Type text to find..." to other one ("Find me!") and also disable alefHamza field
ContentControl findToolBar = documentViewer.Template.FindName("PART_FindToolBarHost", documentViewer) as ContentControl;
if (findToolBar == null) return;
Type baseType = findToolBar.Content.GetType();
MemberInfo[] dynMethod = baseType.GetMember("OptionsMenuItem", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo alefHamzaField = (dynMethod[0] as FieldInfo);
System.Windows.Controls.MenuItem menuItem = alefHamzaField.GetValue(findToolBar.Content) as System.Windows.Controls.MenuItem;
menuItem.Visibility = System.Windows.Visibility.Collapsed;
dynMethod = baseType.GetMember("FindTextLabel", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo findTextLabel = (dynMethod[0] as FieldInfo);
System.Windows.Controls.Label lbl = findTextLabel.GetValue(findToolBar.Content) as System.Windows.Controls.Label;
lbl.Content = "Find me!"
Thanks for watching!
No comments:
Post a Comment