开发者

My silveright page only shows my custom UserControl

开发者 https://www.devze.com 2023-01-26 00:20 出处:网络
I am trying to write my own UserControl - an \"editable\" ComboBox, so the the user can write the name of the item he wants (not relevant to my question, though). I decided to implement it with a User

I am trying to write my own UserControl - an "editable" ComboBox, so the the user can write the name of the item he wants (not relevant to my question, though). I decided to implement it with a User Control (and not a custom control), so I created the following xaml:

<UserControl x:Class="EnhancedCombBox.Silverlight.EnhancedComboBox"> 
    <Canvas Height="25" Width="160">
        <ComboBox x:Name="combo" Width="160" Height="25" SelectionChanged="combo_SelectionChanged" ItemsSource="{Bindin开发者_如何学JAVAg}"></ComboBox>
        <TextBox x:Name="txtBox" Height="25" Width="140" TextChanged="txtBox_TextChanged" KeyUp="txtBox_KeyUp" KeyDown="txtBox_KeyDown" GotFocus="txtBox_GotFocus"></TextBox>
    </Canvas>

(I removed the namespaces to make the xaml shorter). I used my new control on my main page as follow:

<UserControl x:Class="ComboBox.Silverlight.MainPage"
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"
xmlns:sdk="clr-namespace:EnhancedCombBox.Silverlight;assembly=EnhancedCombBox.Silverlight"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">

<StackPanel>
    <Button>OK</Button>
    <sdk:EnhancedComboBox></sdk:EnhancedComboBox>
</StackPanel>

As you can see, I created a simple StackPanel Layout with a Button and my new control. On the designer everything looks normal - I see both the Button and my control underneath. But when I run it - only my control is being displayed. Can someone please explain to me what am I missing?


I've tried your code and work correctly in my system. Try to change browser. Which version of Silverlight are you using. I've tried in SilverLight 4.

0

精彩评论

暂无评论...
验证码 换一张
取 消