开发者

how to insert image dynamically in textbox wpf

we often see any ajax based website where textbox is placed for searching data. when we write something in the textbox and when data is fetching then a spinner gif images is shown in the tex开发者_开发百科tbox with right align. i know this done via css. so how can i achieve the same effect in wpf where textbox will be there and user will write something in the textbox and when data will be fetch then a spinning gif image will show in the textbox with right align and when data fetch will be completed then image will be invisible. please guide me with sample code if possible. thanks


To get you started, look at Data Validation in WPF, specifically, look for the section on Providing Visual Feedback with the AdornedElementPlaceHolder class in WPF.

<AdornedElementPlaceholder/>

It is my belief that this mechanism could be relatively easily adapted to solving your particular problem.

Edit: Additional info

In your case, you'll create a control template for a TextBox and assign that control template to your textbox element. This example varies from the example in the link by changing the TextBox to an Image element. The TextBox in the example in the link is the red character that represents some sort of validation error.

<ControlTemplate x:Key="validationTemplate">
    <DockPanel>
        <Image Source="<location of your animated gif>">
        <AdornedElementPlaceholder/>
    </DockPanel>
</ControlTemplate>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜