Posted 2 December 2020, 8:57 am EST
Is there a way to hide the tags in the C1MultiSelct control?
Forums Home / ComponentOne / WPF Edition
Posted by: elogsdon on 2 December 2020, 8:57 am EST
Posted 2 December 2020, 8:57 am EST
Is there a way to hide the tags in the C1MultiSelct control?
Posted 2 December 2020, 4:32 pm EST
Hi Eric,
You can use C1TagEditor’s TagInserted event to hide the added Tags using C1MultiSelect’s Loaded event as follows:
private void MultiSelectLoaded(object sender, RoutedEventArgs e)
{
var tagEditor = multiSelect.Template.FindName("Editor", multiSelect) as C1TagEditor;
tagEditor.TagInserted += (s, b) => {
tagEditor.Tags[tagEditor.Tags.Count - 1].Visibility = Visibility.Collapsed;
};
}
Just in case if you want to prevent the adding of Tags then you can use C1TagEditor’s TagInserting event as follows:
private void MultiSelectLoaded(object sender, RoutedEventArgs e)
{
var tagEditor = multiSelect.Template.FindName("Editor", multiSelect) as C1TagEditor;
tagEditor.TagInserting += (s, a) => { a.Cancel = true; };
}
Please refer the same from the attached sample. (see MultiSelectTagHide.zip)
Regards,
Kartik
Posted 3 December 2020, 8:52 am EST - Updated 3 October 2022, 11:46 pm EST
Kartik,
I tried the sample code you sent me and am getting a runtime error in the ReportViewer: [ERROR}: The specified object must not be an instance of a generic type. Parameter name: obj
The code looks like this
public partial class LogViewer : UserControl
{
public LogViewer()
{
InitializeComponent();
LogSourceSelector.Loaded += LogSourceSelector_Loaded;
}
private void LogSourceSelector_Loaded(object sender, RoutedEventArgs e)
{
var tagEditor = LogSourceSelector.Template.FindName("Editor", LogSourceSelector) as C1TagEditor; ;
tagEditor.TagInserted += (s, b) =>
{
tagEditor.Tags[tagEditor.Tags.Count - 1].Visibility = Visibility.Collapsed;
};
}
}
The screen looks like this:
What I am trying to accomplish is to hide the circled area here:
Thanks,
Eric.
Posted 3 December 2020, 6:45 pm EST
Hi Eric,
I am not sure why you are getting the error in ReportViewer. Could you please share a stripped-down sample showing this behavior?
However, in order to hide the header area, you can also use C1DropDown’s Header property inside the MultiSelect’s Loaded event as follows:
private void MultiSelectLoaded(object sender, RoutedEventArgs e)
{
var dropDown = multiSelect.Template.FindName("DropDown", multiSelect) as C1DropDown;
(dropDown.Header as Grid).Visibility = Visibility.Hidden;
}
Please refer to the same from the attached sample. (see MultiSelect_Mod.zip)
Regards,
Kartik
Posted 4 December 2020, 3:26 am EST
Kartik,
I switched to the code you sent to hide the DropDown and get the same error. I’ve attached a zip file containing the following items:
"
“The xaml for the view”
“The view code behind”
“The view model that populates the items in the MultiSelect”
"
Code.zip
Posted 7 December 2020, 5:52 pm EST - Updated 3 October 2022, 11:46 pm EST
Hi Eric,
I apologize for the delay in response.
However, this issue is not reproducible at my end with the provided code. Could you please share a working sample replicating the issue along with the report used?
And also please share the C1 version you are using? In case you are using an older version could you please try upgrading to the latest build i.e 4.5.20203.727 using C1ControlPanel and see if the issue exists?
Navigate to Products > Install.
Select version ‘2020v3(727)’ in available versions Combobox (WPF Edition).
Click Proceed.
Regards,
Kartik
Posted 10 December 2020, 8:46 am EST - Updated 3 October 2022, 11:46 pm EST
Kartik,
I upgraded to 2020v3 (I was running 2020v2). The error in the report viewer is due to the fact that I haven’t initialized the parameters yet.
I am still having an issue hiding the tags in the multiselect control. The tags are gone but the header still grows when I check a selection as if it is reserving space for the tag. (see screen shot). I have included a sample app that demonstrates this behaviour.
Thank you,
Eric
Posted 11 December 2020, 2:34 am EST - Updated 3 October 2022, 11:46 pm EST
I forgot to mention, click on the View Event Log button to see the screen in question.
Posted 13 December 2020, 4:40 pm EST
Hi Eric,
Thank you for sharing the snapshots.
It seems like your attached sample is missing. However, you may set the C1MultiSelect’s MaxHeaderItems property to ‘0’ as follows:
multiSelect.MaxHeaderItems = 0;
And also it seems like the behavior is because of the auto Height for C1MultiSelect. Therefore, you may also try setting the Height property of C1MultiSelect.
Regards,
Kartik
Posted 14 December 2020, 6:24 am EST
Kartik,
Thank you. The MaxHeaderItems=“0” gave me the effect I wanted. Sorry about forgetting the code zip.
Thanks,
Eric