Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I add a resource to a silverlight custom control?
    primarykey
    data
    text
    <p>I am trying to trim the selected value of a silverlight custom control combobox. I have found that using the IValueConverter class should be the way to go. So I create this in my library </p> <pre><code>public class StringTrimmer : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return value.ToString().Trim(); } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } </code></pre> <p>this is the xaml for the combobox</p> <pre><code>&lt;UserControl x:Class="SilverlightControlLibrary.SilverlightComboBoxControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Height="25" Width="122"&gt; &lt;ComboBox Height="23" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" Margin="0,0,0,0" Name="ModuleIDFilterCB" ItemsSource="{Binding Path=Screen.LicenseModuleIDs, Mode=TwoWay}" DisplayMemberPath="LicenseModuleName" SelectedItem="{Binding Screen.bufferProp, Converter={StaticResource StringTrimmer},Mode=TwoWay}" /&gt; &lt;/UserControl&gt; </code></pre> <p>Except that the resource "StringTrimmer" for the SelectedItem can't be resolved. I tried adding this reference to the xaml and it still didnt work.</p> <pre><code>xmlns:c="clr-namespace:SilverlightControlLibrary" </code></pre> <p>EDIT: I also tried this</p> <pre><code>xmlns:custom="clr-namespace:SilverlightControlLibrary" </code></pre> <p>along with</p> <pre><code>SelectedItem="{Binding Screen.bufferProp, Converter= {StaticResource custom:StringTrimmer}, Mode=TwoWay}" </code></pre> <p>to no avail..</p> <p>This <a href="http://msdn.microsoft.com/en-us/library/cc189061%28v=vs.95%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/cc189061%28v=vs.95%29.aspx</a> is what microsof has to say about XAML namespaces</p> <p>and this <a href="http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.convert.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.convert.aspx</a> is for the IValueConverter</p> <p>Where am I going wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload